上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 44 下一页
摘要: Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of sto 阅读全文
posted @ 2019-05-07 22:44 Grandyang 阅读(7826) 评论(4) 推荐(0) 编辑
摘要: Given a non empty, singly linked list with head node , return a middle node of linked list. If there are two middle nodes, return the second middle no 阅读全文
posted @ 2019-05-06 01:00 Grandyang 阅读(3344) 评论(0) 推荐(0) 编辑
摘要: Koko loves to eat bananas. There are piles of bananas, the th pile has bananas. The guards have gone and will come back in hours. Koko can decide her 阅读全文
posted @ 2019-05-03 23:43 Grandyang 阅读(5513) 评论(1) 推荐(1) 编辑
摘要: A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: : turn left 90 degr 阅读全文
posted @ 2019-05-01 22:17 Grandyang 阅读(2809) 评论(0) 推荐(1) 编辑
摘要: In an array A containing only 0s and 1s, a *K-bit flip *consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 i 阅读全文
posted @ 2019-04-29 23:48 Grandyang 阅读(2128) 评论(7) 推荐(0) 编辑
摘要: A sequence is fibonacci like if: for all `i + 2 这道题给了我们一个数组,让找其中最长的斐波那契序列,既然是序列而非子数组,那么数字就不必挨着,但是顺序还是需要保持,题目中说了数组是严格递增的,其实博主认为这个条件可有可无的,反正又不能用二分搜索。关于斐 阅读全文
posted @ 2019-04-27 23:59 Grandyang 阅读(2984) 评论(0) 推荐(0) 编辑
摘要: Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t 阅读全文
posted @ 2019-04-25 23:27 Grandyang 阅读(2188) 评论(0) 推荐(0) 编辑
摘要: Given two arrays and of equal size, the advantage of with respect to is the number of indices for which . Return any permutation of that maximizes its 阅读全文
posted @ 2019-04-23 22:36 Grandyang 阅读(2660) 评论(0) 推荐(0) 编辑
摘要: Starting with a positive integer , we reorder the digits in any order (including the original order) such that the leading digit is not zero. Return i 阅读全文
posted @ 2019-04-21 23:57 Grandyang 阅读(2427) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer , find and return the longest distance between two consecutive 1's in the binary representation of . If there aren't two cons 阅读全文
posted @ 2019-04-19 22:52 Grandyang 阅读(1844) 评论(1) 推荐(0) 编辑
摘要: Given a matrix , return the transpose of . The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indic 阅读全文
posted @ 2019-04-17 23:29 Grandyang 阅读(2149) 评论(0) 推荐(0) 编辑
摘要: Find the smallest prime palindrome greater than or equal to . Recall that a number is prime if it's only divisors are 1 and itself, and it is greater 阅读全文
posted @ 2019-04-15 23:04 Grandyang 阅读(2734) 评论(1) 推荐(0) 编辑
摘要: Given a binary tree rooted at , the depth of each node is the shortest distance to the root. A node is deepest if it has the largest depth possible am 阅读全文
posted @ 2019-04-13 23:53 Grandyang 阅读(2964) 评论(0) 推荐(0) 编辑
摘要: We are given a binary tree (with root node ), a node, and an integer value . Return a list of the values of all nodes that have a distance from the no 阅读全文
posted @ 2019-04-10 23:18 Grandyang 阅读(6995) 评论(0) 推荐(0) 编辑
摘要: We have a two dimensional matrix where each value is or . A move consists of choosing any row or column, and toggling each value in that row or column 阅读全文
posted @ 2019-04-08 23:55 Grandyang 阅读(2278) 评论(1) 推荐(0) 编辑
摘要: At a lemonade stand, each lemonade costs . Customers are standing in a queue to buy from you, and order one at a time (in the order specified by ). Ea 阅读全文
posted @ 2019-04-06 23:45 Grandyang 阅读(1986) 评论(0) 推荐(0) 编辑
摘要: Given two strings and of lowercase letters, return if and only if we can swap two letters in so that the result equals . Example 1: Example 2: Example 阅读全文
posted @ 2019-04-04 23:33 Grandyang 阅读(2654) 评论(0) 推荐(0) 编辑
摘要: There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining c 阅读全文
posted @ 2019-04-02 22:56 Grandyang 阅读(3298) 评论(0) 推荐(2) 编辑
摘要: Given a balanced parentheses string , compute the score of the string based on the following rule: has score 1 has score , where A and B are balanced 阅读全文
posted @ 2019-03-31 23:55 Grandyang 阅读(4107) 评论(0) 推荐(0) 编辑
摘要: In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. When a student enters the room, they must sit in the seat that maximiz 阅读全文
posted @ 2019-03-28 22:59 Grandyang 阅读(5085) 评论(2) 推荐(0) 编辑
摘要: cars are going to the same destination along a one lane road. The destination is miles away. Each car has a constant speed (in miles per hour), and in 阅读全文
posted @ 2019-03-15 23:15 Grandyang 阅读(3825) 评论(0) 推荐(1) 编辑
摘要: Let's call an array a mountain if the following properties hold: There exists some Given an array that is definitely a mountain, return any such that 阅读全文
posted @ 2019-03-13 23:57 Grandyang 阅读(3214) 评论(0) 推荐(0) 编辑
摘要: In a group of N people (labelled `0, 1, 2, ..., N-1`), each person has different amounts of money, and different levels of quietness. For convenience, 阅读全文
posted @ 2019-03-11 23:26 Grandyang 阅读(2033) 评论(0) 推荐(0) 编辑
摘要: In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least 阅读全文
posted @ 2019-03-09 23:54 Grandyang 阅读(5818) 评论(2) 推荐(1) 编辑
摘要: There are piles of stones arranged in a row. The th pile has stones. A move consists of merging exactly consecutive piles into one pile, and the cost 阅读全文
posted @ 2019-03-07 23:35 Grandyang 阅读(5944) 评论(9) 推荐(0) 编辑
摘要: We have a string S of lowercase letters, and an integer array shifts. Call the shift of a letter, the next letter in the alphabet, (wrapping around so 阅读全文
posted @ 2019-03-05 22:06 Grandyang 阅读(2221) 评论(0) 推荐(0) 编辑
摘要: Alice has a hand of cards, given as an array of integers. Now she wants to rearrange the cards into groups so that each group is size W, and consists 阅读全文
posted @ 2019-03-03 23:46 Grandyang 阅读(3345) 评论(0) 推荐(0) 编辑
摘要: Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such t 阅读全文
posted @ 2019-03-01 23:49 Grandyang 阅读(3673) 评论(0) 推荐(0) 编辑
摘要: Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S = 阅读全文
posted @ 2019-02-27 23:25 Grandyang 阅读(5247) 评论(0) 推荐(0) 编辑
摘要: Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequen 阅读全文
posted @ 2019-02-25 23:58 Grandyang 阅读(3188) 评论(2) 推荐(1) 编辑
摘要: Given a binary search tree and a node in it, find the in-order successor of that node in the BST. The successor of a node p is the node with the small 阅读全文
posted @ 2019-02-23 23:56 Grandyang 阅读(4021) 评论(3) 推荐(0) 编辑
摘要: There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next r 阅读全文
posted @ 2019-02-21 22:33 Grandyang 阅读(2881) 评论(0) 推荐(0) 编辑
摘要: A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Gi 阅读全文
posted @ 2019-02-19 23:50 Grandyang 阅读(5310) 评论(0) 推荐(0) 编辑
摘要: There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to t 阅读全文
posted @ 2019-02-17 23:57 Grandyang 阅读(3972) 评论(3) 推荐(2) 编辑
摘要: Alice plays the following game, loosely based on the card game "21". Alice starts with 0 points, and draws numbers while she has less than K points. D 阅读全文
posted @ 2019-02-15 23:58 Grandyang 阅读(6715) 评论(3) 推荐(1) 编辑
摘要: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates 阅读全文
posted @ 2019-02-12 23:43 Grandyang 阅读(4489) 评论(2) 推荐(1) 编辑
摘要: Your car starts at position 0 and speed +1 on an infinite number line. (Your car can go into negative positions.) Your car drives automatically accord 阅读全文
posted @ 2019-02-10 23:46 Grandyang 阅读(6564) 评论(4) 推荐(0) 编辑
摘要: Two images A and B are given, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.) We translate on 阅读全文
posted @ 2019-02-07 21:44 Grandyang 阅读(5627) 评论(3) 推荐(1) 编辑
摘要: To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each repla 阅读全文
posted @ 2019-02-04 22:42 Grandyang 阅读(3905) 评论(0) 推荐(0) 编辑
摘要: Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means t 阅读全文
posted @ 2019-02-02 23:56 Grandyang 阅读(2164) 评论(1) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 44 下一页
Fork me on GitHub