標籤:: Go

0

Reverse String II

Reverse String IIGiven a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, r

0

K-diff Pairs in an Array

K-diff Pairs in an ArrayGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i

0

Minimum Absolute Difference in BST

Minimum Absolute Difference in BSTGiven a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. For Example:12345678910111213Input: 1

0

Detect Capital

Detect CapitalGiven a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All le

0

Relative Ranks

Relative RanksGiven scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”. For

0

Base 7

Base 7Given an integer, return its base 7 string representation. Example 1:12Input: 100Output: "202" Example 2:12Input: -7Output: "-10" Note: The input will be in range of [-1e7,

0

Find Mode in Binary Search Tree

Find Mode in Binary Search TreeGiven a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is defined as follows: The

0

Keyboard Row

Keyboard RowGiven a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. For Example:12Input: ["Hello",

0

Next Greater Element I

Next Greater Element IYou are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the correspon

0

Heaters

HeatersWinter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. Now, you are given positions of houses and heaters on a horizo

0

Construct the Rectangle

Construct the RectangleFor a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular

0

Max Consecutive Ones

Max Consecutive OnesGiven a binary array, find the maximum number of consecutive 1s in this array. For Example:1234Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three dig

0

Number Complement

Number ComplementGiven a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within

0

Island Perimeter

Island PerimeterYou are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The gr

0

Hamming Distance

Hamming DistanceThe Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note:0

0

Assign Cookies

Assign CookiesAssume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimu

0

Minimum Moves to Equal Array Elements

Minimum Moves to Equal Array ElementsGiven a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements

0

Find All Numbers Disappeared in an Array

Find All Numbers Disappeared in an ArrayGiven an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive

0

Number of Boomerangs

Number of BoomerangsGiven n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k

0

Arranging Coins

Arranging CoinsYou have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can b

0

Find All Anagrams in a String

Find All Anagrams in a StringGiven a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of both stri

0

Path Sum III

Path Sum IIIYou are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf,