- 博客(138)
- 收藏
- 关注
转载 286. Walls and Gates
You are given am x n2D grid initialized with these three possible values. -1- A wall or an obstacle. 0- A gate. INF- In...
2017-08-09 03:03:00
53
转载 26. Remove Duplicates from Sorted Array i && ii
Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length. Do not allocate extra sp...
2017-08-09 03:03:00
36
转载 341. Flatten Nested List Iterator
Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be...
2017-08-09 03:03:00
50
转载 311. Sparse Matrix Multiplication
Given twosparse matricesAandB, return the result ofAB. You may assume thatA's column number is equal toB's row number. Example: A = [...
2017-08-09 03:03:00
60
转载 150. Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression inReverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or ano...
2017-08-09 03:03:00
50
转载 13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 罗马数字有如下符号: ...
2017-08-09 03:03:00
49
转载 161. One Edit Distance
Given two strings S and T, determine if they are both one edit distance apart. public class Solution { public boolean isOneEditDistance(S...
2017-08-09 03:03:00
61
转载 K closest point to the origin
Give n points on 2-D plane, find the K closest points to origin 13 public List<Point> KClosest(List<Point> input, int k) {14...
2017-08-09 03:03:00
173
转载 366. Find Leaves of Binary Tree
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example: G...
2017-08-09 03:03:00
104
转载 301. Remove Invalid Parentheses
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string...
2017-08-09 03:03:00
49
转载 274. H-Index
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. Acc...
2017-08-09 03:03:00
60
转载 34. Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime co...
2017-08-09 03:03:00
46
转载 205. Isomorphic Strings
Given two stringssandt, determine if they are isomorphic. Two strings are isomorphic if the characters inscan be replaced to gett. All o...
2017-08-09 03:03:00
56
转载 90. Subsets II
Given a collection of integers that might contain duplicates,nums, return all possible subsets. Note:The solution set must not contain ...
2017-08-09 03:03:00
49
转载 269. Alien Dictionary
There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list ofnon-empty...
2017-08-09 03:03:00
57
转载 10. Regular Expression Matching
implement regular expression matching with support for'.'and'*'. '.' Matches any single character.'*' Matches zero or more of the pre...
2017-08-09 03:03:00
48
转载 108. Convert Sorted Array to Binary Search Tree
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(i...
2017-08-09 03:03:00
49
转载 168. Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C...
2017-08-09 03:03:00
69
转载 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...
2017-08-09 03:03:00
55
转载 Convert a Binary Tree to Doubly Linked List
/*Convert a binary search tree to doubly linked list with in-order traversal.ExampleGiven a binary search tree: 4 / \ 2 5 / \1...
2017-08-09 03:03:00
110
转载 264. Ugly Number II
Write a program to find then-th ugly number. Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,1, 2, 3, ...
2017-08-09 03:03:00
51
转载 88. Merge Sorted Array
Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array. Note: You may assume thatnums1has enough space ...
2017-08-09 03:03:00
67
转载 228. Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges. For example, given[0,1,2,4,5,7], return["0->2","4->5"...
2017-08-09 03:03:00
58
转载 200. Number of Islands
Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adj...
2017-08-09 03:03:00
58
转载 297. Serialize and Deserialize Binary Tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer,...
2017-08-09 03:03:00
62
转载 69. Sqrt(x)
Implementint sqrt(int x). Compute and return the square root ofx. public class Solution { public int mySqrt(int num) { if(n...
2017-08-09 03:03:00
63
转载 67. Add Binary
Given two binary strings, return their sum (also a binary string). For example, a ="11" b ="1" Return"100". public class Solution { ...
2017-08-09 03:03:00
64
转载 238. Product of Array Except Self
Given an array ofnintegers wheren>1,nums,return anarrayoutputsuchthatoutput[i]isequal to the product of all the elementsofnums...
2017-08-09 03:03:00
66
转载 173. Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Callingnext()will return...
2017-08-09 03:03:00
52
转载 98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node con...
2017-08-09 03:03:00
51
转载 314. Binary Tree Vertical Order Traversal
Given a binary tree, return thevertical ordertraversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes a...
2017-08-09 03:03:00
59
转载 121. Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most on...
2017-08-09 03:03:00
55
转载 209. Minimum Size Subarray Sum
Given an array ofnpositive integers and a positive integers, find the minimal length of acontiguoussubarray of which the sum ≥s. If there is...
2017-08-09 03:03:00
59
转载 325. Maximum Size Subarray Sum Equals k
Given an arraynumsand a target valuek, find the maximum length of a subarray that sums tok. If there isn't one, return 0 instead. Note: The ...
2017-08-09 03:03:00
77
转载 23. Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity. /** * Definition for singly-linked list....
2017-08-09 03:03:00
62
转载 543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath b...
2017-08-09 03:03:00
80
转载 46. Permutations
Given a collection ofdistinctnumbers, return all possible permutations. For example, [1,2,3]have the following permutations: [ [1,2,3], ...
2017-08-09 03:03:00
90
转载 127. Word Ladder
Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWo...
2017-08-09 03:03:00
77
转载 91. Decode Ways
A message containing letters fromA-Zis being encoded to numbers using the following mapping: 'A' -> 1'B' -> 2...'Z' -> 26 Given a...
2017-08-09 03:03:00
101
转载 47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2]have the following un...
2017-08-09 03:02:00
52
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人