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

2018年8月11日

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 猪猪🐷 阅读(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 猪猪🐷 阅读(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 猪猪🐷 阅读(123) 评论(0) 推荐(0)

k sorted list iterator.

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

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

merge sorted iterator

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

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

2018年8月10日

281 Zigzag Iterator

摘要: Given two 1d vectors, implement an iterator to return their elements alternately. Example: Follow up: What if you are given k 1d vectors? How well can 阅读全文

posted @ 2018-08-10 16:31 猪猪🐷 阅读(81) 评论(0) 推荐(0)

647. Palindromic Substrings

摘要: Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c 阅读全文

posted @ 2018-08-10 15:32 猪猪🐷 阅读(92) 评论(0) 推荐(0)

140. Word Break II

摘要: 140. Word Break II dfs + memo Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct 阅读全文

posted @ 2018-08-10 15:26 猪猪🐷 阅读(142) 评论(0) 推荐(0)

170 Two Sum III - Data structure design

摘要: Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find 阅读全文

posted @ 2018-08-10 15:25 猪猪🐷 阅读(118) 评论(0) 推荐(0)

347. Top K Frequent Elements

摘要: Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input 阅读全文

posted @ 2018-08-10 15:19 猪猪🐷 阅读(128) 评论(0) 推荐(0)

146 LRU Cache

摘要: 这个题的 node class, constructor, global vars , 怎么写 该注意 几点该注意的: use helper functions, add, and deleteNode, add : add node to the front, deleteNode: delete 阅读全文

posted @ 2018-08-10 15:18 猪猪🐷 阅读(173) 评论(0) 推荐(0)

126 Word Ladder II

摘要: 126. Word Ladder II Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that: 1. Only one letter can... 阅读全文

posted @ 2018-08-10 15:12 猪猪🐷 阅读(272) 评论(0) 推荐(0)

395 Longest Substring with At Least K Repeating Characters

摘要: Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than  阅读全文

posted @ 2018-08-10 15:07 猪猪🐷 阅读(369) 评论(0) 推荐(0)

247. Strobogrammatic Number II

摘要: 1 1 1 1 1 6 6 8 9 9 8 9 0 6 6 9 8 8 8 0 0 So we Cann’t have 0 at the very out side of the number Since any number with leading 0 is not valid And then 阅读全文

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

282 Expression Add Operators

摘要: Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the d 阅读全文

posted @ 2018-08-10 15:03 猪猪🐷 阅读(131) 评论(0) 推荐(0)

227. Basic Calculator II

摘要: we have a string, can look like 32 + 2 * 46 And we are not sure if there is any white space anywhere in the string So we use s = s.replaceAll(" ", "") 阅读全文

posted @ 2018-08-10 15:00 猪猪🐷 阅读(134) 评论(0) 推荐(0)

10. Regular Expression Matching

摘要: Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The matching should cover the entire  阅读全文

posted @ 2018-08-10 14:52 猪猪🐷 阅读(75) 评论(0) 推荐(0)

44 Wildcard Matching

摘要: Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching should cover the entire in 阅读全文

posted @ 2018-08-10 14:51 猪猪🐷 阅读(88) 评论(0) 推荐(0)

112. Path Sum

摘要: 112. Path Sum https://www.youtube.com/watch?v=zdClzfnkvDY Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that addin 阅读全文

posted @ 2018-08-10 14:50 猪猪🐷 阅读(101) 评论(0) 推荐(0)

124. Binary Tree Maximum Path Sum

摘要: 124. Binary Tree Maximum Path Sum https://github.com/tongzhang1994/Facebook-Interview-Coding/blob/master/Longest%20Path%20in%20Binary%20Tree.java http 阅读全文

posted @ 2018-08-10 14:49 猪猪🐷 阅读(86) 评论(0) 推荐(0)

437 Path Sum III (Find the number of paths that sum to a given value.)

摘要: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文

posted @ 2018-08-10 14:48 猪猪🐷 阅读(123) 评论(0) 推荐(0)

113. Path Sum II (find all root-to-leaf paths where each path's sum equals the given sum.)

摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Exampl 阅读全文

posted @ 2018-08-10 14:48 猪猪🐷 阅读(125) 评论(0) 推荐(0)

34 Find First and Last Position of Element in Sorted Array

摘要: 这个也是, 得自己走例子, 才知道什么时候需要post processing , 什么时候不需要, 这个题一个问不需要, 第二问就需要了 所以不要背答案, 要真的理解, 自己走例子 Your algorithm's runtime complexity must be in the order of 阅读全文

posted @ 2018-08-10 14:47 猪猪🐷 阅读(556) 评论(0) 推荐(0)

491 Increasing Subsequences

摘要: Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing su 阅读全文

posted @ 2018-08-10 14:46 猪猪🐷 阅读(132) 评论(0) 推荐(0)

65. Valid Number

摘要: Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for the 阅读全文

posted @ 2018-08-10 14:46 猪猪🐷 阅读(140) 评论(0) 推荐(0)

381. Insert Delete GetRandom O(1) - Duplicates allowed

摘要: 381. Insert Delete GetRandom O(1) - Duplicates allowed Design a data structure that supports all following operations in average O(1) time. Note: Duplicate elements are allowed. 1. insert(val): Ins... 阅读全文

posted @ 2018-08-10 14:44 猪猪🐷 阅读(143) 评论(0) 推荐(0)

57 Insert Interval

摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文

posted @ 2018-08-10 14:43 猪猪🐷 阅读(108) 评论(0) 推荐(0)

56. Merge Intervals

摘要: merge intervals leetcode 88 merge interval的变体, 问了下时间复杂度,求interval所覆盖区间的总长度。Follow up: nlogn的排序算法有哪些。哪些排序算法是稳定的。解释为什么quick sort不稳定。我没想到没问这么基础的问题,答得一般般啦 阅读全文

posted @ 2018-08-10 14:42 猪猪🐷 阅读(147) 评论(0) 推荐(0)

380 Insert Delete GetRandom O(1)

摘要: 380 Insert Delete GetRandom O(1) Design a data structure that supports all following operations in average O(1) time. 1. insert(val): Inserts an item val to the set if not already present. 2. remo... 阅读全文

posted @ 2018-08-10 14:41 猪猪🐷 阅读(111) 评论(0) 推荐(0)

246  Strobogrammatic Number I

摘要: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number i 阅读全文

posted @ 2018-08-10 14:40 猪猪🐷 阅读(90) 评论(0) 推荐(0)

127 Word Ladder

摘要: Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文

posted @ 2018-08-10 14:39 猪猪🐷 阅读(143) 评论(0) 推荐(0)

346. Moving Average from Data Stream

摘要: the next() func takes in an integer, First check if the queue size() == maxSize if it’s the same, then we poll the top, which is the one we added firs 阅读全文

posted @ 2018-08-10 14:38 猪猪🐷 阅读(145) 评论(0) 推荐(0)

53 Maximum Subarray

摘要: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll 阅读全文

posted @ 2018-08-10 14:36 猪猪🐷 阅读(82) 评论(0) 推荐(0)

129 Sum Root to Leaf Numbers (An example is the root-to-leaf path 1->2->3 which represents the number 123.)

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

posted @ 2018-08-10 14:35 猪猪🐷 阅读(83) 评论(0) 推荐(0)

692 Top K Frequent Words

摘要: 这个写的少, pq 里存的 是 map.entry<string, integer> 自己 这些 comparator overide 要专门写, 然后 maxheap(a,b). a < b, return 1 minheap(a, b) a < b, return -1 map.entryset 阅读全文

posted @ 2018-08-10 14:34 猪猪&#128055; 阅读(169) 评论(0) 推荐(0)

2018年8月9日

417. Pacific Atlantic Water Flow

摘要: Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top 阅读全文

posted @ 2018-08-09 19:07 猪猪&#128055; 阅读(117) 评论(0) 推荐(0)

733. Flood Fill

摘要: An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, 阅读全文

posted @ 2018-08-09 19:06 猪猪&#128055; 阅读(105) 评论(0) 推荐(0)

317. Shortest Distance from All Buildings

摘要: You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. 阅读全文

posted @ 2018-08-09 19:04 猪猪&#128055; 阅读(194) 评论(0) 推荐(0)

567. Permutation in String

摘要: Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutati 阅读全文

posted @ 2018-08-09 19:02 猪猪&#128055; 阅读(83) 评论(0) 推荐(0)

269. alien dictionary

摘要: Using “break” in for loop public class Test { public static void main(String args[]) { int [] numbers = {10, 20, 30, 40, 50}; for(int x : numbers ) { 阅读全文

posted @ 2018-08-09 19:00 猪猪&#128055; 阅读(183) 评论(0) 推荐(0)

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

导航