- 博客(153)
- 资源 (7)
- 问答 (1)
- 收藏
- 关注
原创 Math Summary
"1 + 1" = 2" 2-1 + 2 " = 3"(1+(4+5+2)-3)+(6+8)" = 23numbers could be more than one digit!!!
2016-05-25 07:42:28 208
原创 LInkedList
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->
2016-05-18 07:28:36 287
原创 Binary Search Summary
Find a place to insert an element[1, 3, 5, 7, 9]insert 4public int find(int start, int end, int key, int[] sums){ while(start <= end){ int mid = (start + end) / 2;
2016-05-08 06:49:30 253
原创 Array Summary
The order of elements can be changed. It doesn't matter what you leave beyond the new length.You can just copy the elements instead of swapping.
2016-05-06 04:00:31 220
原创 220. Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i an
2016-04-25 05:42:16 372
原创 307. Range Sum Query - Mutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Examp
2016-04-23 11:57:48 201
原创 284. Peeking Iterator
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be
2016-04-23 05:04:20 358
原创 130. Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O X
2016-04-23 03:45:31 203
原创 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 adjacent lands horizontally or vertically. You may assu
2016-04-22 14:38:06 225
原创 210. Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as
2016-04-22 14:23:13 217
原创 207. Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as
2016-04-22 02:58:27 178
原创 133. Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.Solution 1 BFS//BFS public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(n
2016-04-20 00:48:12 205
原创 129. Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum
2016-04-19 02:51:41 164
原创 199. Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1
2016-04-19 02:09:50 180
原创 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2016-04-18 02:25:26 244
原创 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 contains only nodes with keys less than the node's key.Th
2016-04-17 03:48:29 253
原创 116. Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.
2016-04-16 12:16:25 254
原创 201. Bitwise AND of Numbers Range
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.Solution1https://yq.aliyun.com/articles/3512// https://yq.aliyun.com/articles/3512 public int r
2016-04-16 11:14:32 183
原创 179. Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be ve
2016-04-16 02:17:49 187
原创 134. Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2016-04-14 08:01:42 130
原创 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.Calling next() will return the next smallest number in the BST.Note: next()
2016-04-14 07:52:27 163
原创 211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only lett
2016-04-12 14:22:31 171
原创 208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class TrieNode { // Initialize your data structure
2016-04-12 14:07:49 167
原创 77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2016-04-11 14:03:00 169
原创 89. Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of
2016-04-11 12:31:40 164
原创 131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ [
2016-04-11 07:14:18 163
原创 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 unique permutations:[1,1,2], [1,2,1], and [2,1
2016-04-10 08:41:53 207
原创 309. Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2016-04-09 02:09:01 135
原创 221. Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0
2016-04-08 03:55:58 140
原创 95. Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3
2016-04-08 02:15:09 190
原创 96. Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2016-04-07 03:00:21 136
原创 222. Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled,
2016-04-07 01:48:34 164
原创 230. Kth Smallest Element in a BST
Given 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.Follow up:What if the
2016-04-06 04:57:18 189
原创 300. Longest Increasing Subsequence
Given 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 is [2, 3, 7, 101], ther
2016-04-06 02:03:41 205
原创 241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +,- and *.Example 1I
2016-04-05 02:11:12 155
原创 215. Kth Largest Element in an Array
Find 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,6,4] and k = 2, return 5.
2016-04-04 10:59:52 161
转载 Ten sort algorithms in interviews
http://www.admin10000.com/document/7042.html
2016-04-04 10:58:02 193
原创 240. Search a 2D Matrix II
Write 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 right.Integers in
2016-04-04 04:35:34 199
原创 91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2016-04-02 05:42:36 194
java Scanner nextLine() 后读不到next()
2016-01-31
TA创建的收藏夹 TA关注的收藏夹
TA关注的人