上一页 1 ··· 9 10 11 12 13 14 15 下一页

2018年8月9日

637 Average of Levels in Binary Tree

摘要: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 阅读全文

posted @ 2018-08-09 17:40 猪猪🐷 阅读(94) 评论(0) 推荐(0)

102 Binary Tree Level Order Traversal

摘要: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文

posted @ 2018-08-09 17:39 猪猪🐷 阅读(169) 评论(0) 推荐(0)

Buy and Sell Stock series

摘要: 121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文

posted @ 2018-08-09 17:39 猪猪🐷 阅读(159) 评论(0) 推荐(0)

49 Group Anagrams

摘要: Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat", 阅读全文

posted @ 2018-08-09 17:38 猪猪🐷 阅读(128) 评论(0) 推荐(0)

680 Valid Palindrome II

摘要: Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Example 2: 阅读全文

posted @ 2018-08-09 17:35 猪猪🐷 阅读(109) 评论(0) 推荐(0)

23. Merge k Sorted Lists

摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: 阅读全文

posted @ 2018-08-09 17:34 猪猪🐷 阅读(93) 评论(0) 推荐(0)

235. Lowest Common Ancestor of a Binary Search Tree

摘要: 带返回值的 recursion Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of 阅读全文

posted @ 2018-08-09 17:34 猪猪🐷 阅读(93) 评论(0) 推荐(0)

286. Walls and Gates

摘要: You are given a m x n 2D grid initialized with these three possible values. Fill each empty room with the distance to its nearest gate. If it is impos 阅读全文

posted @ 2018-08-09 17:33 猪猪🐷 阅读(119) 评论(0) 推荐(0)

242. Valid Anagram

摘要: Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only 阅读全文

posted @ 2018-08-09 17:32 猪猪🐷 阅读(82) 评论(0) 推荐(0)

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, w 阅读全文

posted @ 2018-08-09 17:31 猪猪🐷 阅读(94) 评论(0) 推荐(0)

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: 阅读全文

posted @ 2018-08-09 17:30 猪猪🐷 阅读(82) 评论(0) 推荐(0)

438. Find All Anagrams in a String (find all the start indices of p's anagrams in s.)

摘要: Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the 阅读全文

posted @ 2018-08-09 17:29 猪猪🐷 阅读(125) 评论(0) 推荐(0)

212. Word Search II

摘要: 再尝试用 isWord boolean 的方式创建 trienode , 做下这道题。 Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be c 阅读全文

posted @ 2018-08-09 17:28 猪猪🐷 阅读(136) 评论(0) 推荐(0)

76 - Minimum Window Substring

摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Note: If there i 阅读全文

posted @ 2018-08-09 17:28 猪猪🐷 阅读(150) 评论(0) 推荐(0)

208 implement trie

摘要: 208 impement trie Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); ... 阅读全文

posted @ 2018-08-09 17:27 猪猪🐷 阅读(216) 评论(0) 推荐(0)

Sparse vector multiplication

摘要: // sparse vector mul // 1. the the vector is sparse , how to save time // only save the non zero element // what data strucure do you want to use to keep the non zero element // use list of list... 阅读全文

posted @ 2018-08-09 17:26 猪猪🐷 阅读(193) 评论(0) 推荐(0)

234. Palindrome Linked List

摘要: 234. Palindrome Linked List Could you do it in O(n) time and O(1) space? O(1) space means no extra space, no extra data structure https://leetcode.com 阅读全文

posted @ 2018-08-09 17:23 猪猪🐷 阅读(85) 评论(0) 推荐(0)

32. Longest Valid Parentheses

摘要: Longest Valid Parentheses https://www.youtube.com/watch?v=M1Vw5Tk1rw4 阅读全文

posted @ 2018-08-09 17:23 猪猪🐷 阅读(99) 评论(0) 推荐(0)

75 - Sort Colors

摘要: 75 - Sort Colors https://www.youtube.com/watch?v=yTwW8WiGrKw 75, sort colors, rainbow sort .. sort k colors Given an array with n objects colored red, 阅读全文

posted @ 2018-08-09 17:22 猪猪🐷 阅读(138) 评论(0) 推荐(0)

29. Divide Two Integers

摘要: Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division sh... 阅读全文

posted @ 2018-08-09 17:21 猪猪🐷 阅读(107) 评论(0) 推荐(0)

给俩排好序的数组,找出两个数组的最小差

摘要: 给俩排好序的数组,找出两个数组的最小差,比如 [3 5 7] [5 9 12], 我这个代码对吗? public int minDifference(int[] a, int[] b){ int i = 0; int j = 0; int result = Math.abs(a[i] - b[j]); while( i b[j]){ result ... 阅读全文

posted @ 2018-08-09 17:17 猪猪🐷 阅读(199) 评论(0) 推荐(0)

80. Remove Duplicates from Sorted Array II

摘要: Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra 阅读全文

posted @ 2018-08-09 17:13 猪猪🐷 阅读(76) 评论(0) 推荐(0)

110. Balanced Binary Tree

摘要: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep 阅读全文

posted @ 2018-08-09 17:12 猪猪🐷 阅读(94) 评论(0) 推荐(0)

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 n 阅读全文

posted @ 2018-08-09 17:11 猪猪🐷 阅读(85) 评论(0) 推荐(0)

333. Largest BST Subtree

摘要: 333. Largest BST Subtree I feel this is post order traversal https://www.youtube.com/watch?v=4fiDs7CCxkc https://leetcode.com/problems/largest-bst-sub 阅读全文

posted @ 2018-08-09 17:11 猪猪🐷 阅读(138) 评论(0) 推荐(0)

98. Validate Binary Search Tree

摘要: 带返回值的 recursion. time: O(N), N is the number of nodes in the bst, space is O(1) , no extra space is used Given a binary tree, determine if it is a val 阅读全文

posted @ 2018-08-09 17:09 猪猪🐷 阅读(103) 评论(0) 推荐(0)

572. Subtree of Another Tree

摘要: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a 阅读全文

posted @ 2018-08-09 17:06 猪猪🐷 阅读(92) 评论(0) 推荐(0)

114. Flatten Binary Tree to Linked List

摘要: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: The flattened tree should look like: 阅读全文

posted @ 2018-08-09 17:04 猪猪🐷 阅读(89) 评论(0) 推荐(0)

253. Meeting Rooms II

摘要: if the new interval's start is later than the smallest end index in our pq. then we can use the same room, and update the end , put it back to the pq. 阅读全文

posted @ 2018-08-09 17:03 猪猪🐷 阅读(129) 评论(0) 推荐(0)

117. Populating Next Right Pointers in Each Node II

摘要: Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL 阅读全文

posted @ 2018-08-09 17:02 猪猪🐷 阅读(75) 评论(0) 推荐(0)

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 阅读全文

posted @ 2018-08-09 16:59 猪猪🐷 阅读(111) 评论(0) 推荐(0)

116. Populating Next Right Pointers in Each Node

摘要: Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL 阅读全文

posted @ 2018-08-09 16:56 猪猪🐷 阅读(92) 评论(0) 推荐(0)

513. Find Bottom Left Tree Value

摘要: Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: 阅读全文

posted @ 2018-08-09 16:55 猪猪🐷 阅读(99) 评论(0) 推荐(0)

545. Boundary of Binary Tree

摘要: Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and ri 阅读全文

posted @ 2018-08-09 16:54 猪猪🐷 阅读(100) 评论(0) 推荐(0)

404. Sum of Left Leaves

摘要: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文

posted @ 2018-08-09 16:51 猪猪🐷 阅读(90) 评论(0) 推荐(0)

2018年7月24日

敬啟者給十五歲的你

摘要: 此刻正讀著這封信的你現在在哪裡 正在做些什麼事呢? 十五歲的我 有著無法向任何人訴說的煩惱 如果是寫給未來的自己的信一定可以坦率的說出來吧 現在 我不行了 我好想哭 好想消失在世界上彷彿下一秒就要消失的我究竟該相信誰的話? 只有一顆心 不斷的崩離破碎在痛苦之中 只能繼續不停地往前走 敬啟者:謝謝你的 阅读全文

posted @ 2018-07-24 03:03 猪猪🐷 阅读(105) 评论(0) 推荐(0)

2018年7月19日

144. Binary Tree Preorder Traversal

摘要: Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,2,3] Follow up: Recursive s 阅读全文

posted @ 2018-07-19 12:41 猪猪🐷 阅读(125) 评论(0) 推荐(0)

94. Binary Tree Inorder Traversal

摘要: Given a binary tree, return the inorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iteratively 阅读全文

posted @ 2018-07-19 12:23 猪猪🐷 阅读(103) 评论(0) 推荐(0)

104. Maximum Depth of Binary Tree

摘要: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文

posted @ 2018-07-19 12:20 猪猪🐷 阅读(76) 评论(0) 推荐(0)

111. Minimum Depth of Binary Tree

摘要: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文

posted @ 2018-07-19 12:19 猪猪🐷 阅读(90) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 下一页

导航