標籤:: Go

0

Additive Number

Additive NumberAdditive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent

0

Range Sum Query 2D - Immutable

Range Sum Query 2D - ImmutableGiven a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). The abov

0

Longest Increasing Subsequence

Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence. For example:Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence

0

Bulls and Cows

Bulls and CowsYou are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you pro

0

Game of Life

Game of LifeAccording to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.” Given a board

0

Find the Duplicate Number

Find the Duplicate NumberGiven an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is onl

0

Perfect Squares

Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. For example:123Given n = 12, return 3 because 12 = 4 + 4 + 4;G

0

H-Index II

H-Index IIFollow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? Default:123func hIndex(citations []int) int {} 解答思路:建議可以先參考先前H-

0

H-Index

H-IndexGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition of h-index on Wikipedia

0

Ugly Number II

Ugly Number IIWrite a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of

0

Single Number III

Single Number IIIGiven an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For examp

0

Different Ways to Add Parentheses

Different Ways to Add ParenthesesGiven a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operator

0

Search a 2D Matrix II

Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to ri

0

Product of Array Except Self

Product of Array Except SelfGiven an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it

0

Kth Smallest Element in a BST

Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ? k ? BST’s total elements. Fol

0

Majority Element II

Majority Element IIGiven an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 提示 解題應用 Array Array/Slice

0

Summary Ranges

Summary RangesGiven a sorted integer array without duplicates, return the summary of its ranges. For example:12345Given [0,1,2,4,5,7],return ["0->2","4->5","7"].

0

Basic Calculator II

Basic Calculator IIImplement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer

0

Rectangle Area

Rectangle AreaFind the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that th

0

Maximal Square

Maximal SquareGiven a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. For example:Given the following matrix: 12341 0 1 0 01 0 1 1 11 1 1 1

0

Combination Sum III

Combination Sum IIIFind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Examp

0

Kth Largest Element in an Array

Kth Largest Element in an ArrayFind the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example,Given [3,2,1,5