2018年8月11日

209. Minimum Size Subarray Sum

摘要: Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文

posted @ 2018-08-11 05:15 猪猪🐷 阅读(120) 评论(0) 推荐(0)

159. Longest Substring with At Most Two Distinct Characters

摘要: Given a string s , find the length of the longest substring t that contains at most 2 distinct characters. Example 1: Example 2: 阅读全文

posted @ 2018-08-11 04:55 猪猪🐷 阅读(120) 评论(0) 推荐(0)

find the length of shortest path between two nodes in a tree

摘要: https://www.geeksforgeeks.org/shortest-path-between-two-nodes-in-array-like-representation-of-binary-tree/ 阅读全文

posted @ 2018-08-11 04:53 猪猪🐷 阅读(84) 评论(0) 推荐(0)

236. Lowest Common Ancestor of a Binary Tree

摘要: time complexity is O(n) Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA 阅读全文

posted @ 2018-08-11 04:52 猪猪🐷 阅读(104) 评论(0) 推荐(0)

199. Binary Tree Right Side View

摘要: ( bfs is easy, instead use preorder dfs right first and then left) Given a binary tree, imagine yourself standing on the right side of it, return the 阅读全文

posted @ 2018-08-11 04:39 猪猪🐷 阅读(107) 评论(0) 推荐(0)

257 binary tree paths

摘要: https://github.com/tongzhang1994/Facebook-Interview-Coding/blob/master/257.%20Binary%20Tree%20Paths.java Given a binary tree, return all root-to-leaf 阅读全文

posted @ 2018-08-11 04:38 猪猪🐷 阅读(104) 评论(0) 推荐(0)

103. Binary Tree Zigzag Level Order Traversal

摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文

posted @ 2018-08-11 04:33 猪猪🐷 阅读(105) 评论(0) 推荐(0)

求只包含素数的数组里面所有元素所有可能的乘积

摘要: not tested yet 阅读全文

posted @ 2018-08-11 04:30 猪猪🐷 阅读(310) 评论(0) 推荐(0)

permutation II

摘要: example: 1 1 1 2 for the first pos, we can chose 1 and 2 , skip the two 1s in the middle , the way we skip these 1s is within the for loop, we only ad 阅读全文

posted @ 2018-08-11 04:29 猪猪🐷 阅读(179) 评论(0) 推荐(0)

653 two sum iv - input is a bst

摘要: 653 two sum iv - input is a bst Approach #1 Using HashSet[Accepted] The simplest solution will be to traverse over the whole tree and consider every p 阅读全文

posted @ 2018-08-11 04:15 猪猪🐷 阅读(133) 评论(0) 推荐(0)

133. Clone Graph

摘要: Given the head of a graph, return a deep copy (clone) of the graph. Each node in the graph contains a label (int) and a list (List[UndirectedGraphNode 阅读全文

posted @ 2018-08-11 03:54 猪猪🐷 阅读(120) 评论(0) 推荐(0)

Find Shortest distance from a guard in a Bank.

摘要: Given a matrix that is filled with ‘O’, ‘G’, and ‘W’ where ‘O’ represents open space, ‘G’ represents guards and ‘W’ represents walls in a Bank. Replac 阅读全文

posted @ 2018-08-11 03:51 猪猪🐷 阅读(386) 评论(0) 推荐(0)

top k closest points to origin, k closest points to <0,0,0>

摘要: 大班文档有java solution 强化 5 x.y z is similar 阅读全文

posted @ 2018-08-11 03:47 猪猪&#128055; 阅读(157) 评论(0) 推荐(0)

120. Triangle

摘要: 120. Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], ... 阅读全文

posted @ 2018-08-11 03:41 猪猪&#128055; 阅读(163) 评论(0) 推荐(0)

377. Combination Sum IV

摘要: 377. Combination Sum IV Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, ... 阅读全文

posted @ 2018-08-11 03:40 猪猪&#128055; 阅读(126) 评论(0) 推荐(0)

221. Maximal Square

摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 阅读全文

posted @ 2018-08-11 03:32 猪猪&#128055; 阅读(107) 评论(0) 推荐(0)

interval intersection

摘要: example: input is two non-overlapping list of intervals , output is the list of overlaps l1 : [0, 2], [5, 7]. [9, 11] l2: [1, 3], [6, 10] overlap is [ 阅读全文

posted @ 2018-08-11 03:23 猪猪&#128055; 阅读(240) 评论(0) 推荐(0)

preorder iterator of binary tree

摘要: 实现 next(), hasNext() . Follow up: 实现 remove, remove 要求删除next()last visited node and its subtree. 阅读全文

posted @ 2018-08-11 03:19 猪猪&#128055; 阅读(123) 评论(0) 推荐(0)

k sorted list iterator.

摘要: k sorted list iterator. 写个被多次 call 的 getNext()。没要求用 iterator, 于是 heap 秒了。面试官表示很满意。 阅读全文

posted @ 2018-08-11 03:18 猪猪&#128055; 阅读(76) 评论(0) 推荐(0)

merge sorted iterator

摘要: merge sorted iterator 这个小班 讲过, 小班文档上应该有 阅读全文

posted @ 2018-08-11 03:17 猪猪&#128055; 阅读(81) 评论(0) 推荐(0)

导航