- 博客(21)
- 收藏
- 关注
原创 231. Power of Two
Given an integer, write a function to determine if it is a power of two.Example 1:Input: 1Output: true Explanation: 20= 1Example 2:Input: 16Output: trueExplanation: 24= 16Example 3:...
2019-06-28 20:46:51 89
转载 43. Multiply Strings
Given two non-negative integersnum1andnum2represented as strings, return the product ofnum1andnum2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Exampl...
2019-06-26 20:06:33 97
原创 16. 3Sum Closest
Given an arraynumsofnintegers and an integertarget, find three integers innumssuch that the sum is closest totarget. Return the sum of the three integers. You may assume that each input would ...
2019-06-26 16:48:53 76
原创 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string"".Example 1:Input: ["flower","flow","flight"]Output:...
2019-06-23 18:54:01 73
原创 LeetCode 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome.Examp...
2019-06-23 18:48:21 76
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note:You ...
2019-06-23 11:28:41 93
原创 LeetCode 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the...
2019-06-16 11:54:47 92
原创 LeetCode 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Example 1:Input:{"$id":"1...
2019-06-12 15:41:08 72
原创 LeetCode 116. Populating Next Right Pointers in Each Node
You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; ...
2019-06-10 16:51:51 87
原创 LeetCode 91. Decode Ways
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, determine t...
2019-06-10 15:38:04 92
原创 LeetCode 54. Spiral Matrix
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]...
2019-06-10 14:57:57 84
原创 LeetCode 912. Sort an Array
Given an array of integersnums, sort the array in ascending order.Example 1:Input:[5,2,3,1]Output: [1,2,3,5]Example 2:Input: [5,1,1,2,0,0]Output: [0,0,1,1,2,5]Note:1 <= A....
2019-06-10 12:06:52 354
原创 LeetCode 127. Word Ladder
Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed at a ti...
2019-06-04 10:22:30 138
原创 LeetCode 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty spaces. The integer division should trun...
2019-06-03 16:34:33 154
原创 LeetCode 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tre...
2019-06-03 15:09:14 87
原创 LeetCode 394. Decode String
Given an encoded string, return it's decoded string.The encoding rule is:k[encoded_string], where theencoded_stringinside the square brackets is being repeated exactlyktimes. Note thatkis gua...
2019-06-02 15:30:42 107
原创 LeetCode 236. Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p...
2019-06-02 14:37:33 85
原创 LeetCode 208. Implement Trie (Prefix Tree)
Implement a trie withinsert,search, andstartsWithmethods.Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns fals...
2019-06-01 19:12:01 84
原创 LeetCode 148. Sort List
Sort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1-...
2019-06-01 16:30:48 74
原创 LeetCode 102. Binary Tree Level Order Traversal
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 20 ...
2019-06-01 14:48:13 93
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人