2019年12月1日

part 1

摘要: COMPSCI 143A. Principles of Operating Systems. Principles and concepts of process and resource management, especially as seen in operating systems. Pr 阅读全文

posted @ 2019-12-01 13:09 猪猪🐷 阅读(83) 评论(0) 推荐(0)

2019年1月21日

947. Most Stones Removed with Same Row or Column

摘要: On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone. Now, a move consists of removing a 阅读全文

posted @ 2019-01-21 00:31 猪猪🐷 阅读(171) 评论(0) 推荐(0)

2018年12月14日

amazon prep

摘要: more on desktop, amazon prep star https://www.thebalancecareers.com/what-is-the-star-interview-response-technique-2061629 8 principles https://www.ama 阅读全文

posted @ 2018-12-14 06:34 猪猪🐷 阅读(270) 评论(0) 推荐(0)

2018年12月11日

298. Binary Tree Longest Consecutive Sequence

摘要: Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any 阅读全文

posted @ 2018-12-11 06:38 猪猪🐷 阅读(125) 评论(0) 推荐(0)

2018年12月6日

160 Find K Closest Elements

摘要: Solution 1 : Log n + k http://www.cnblogs.com/grandyang/p/7519466.html https://shineboy2013.github.io/2018/01/28/lee-658/ // correct class Solution { 阅读全文

posted @ 2018-12-06 21:53 猪猪🐷 阅读(176) 评论(0) 推荐(0)

162. Find Peak Element

摘要: A peak element is an element that is greater than its neighbors. Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return 阅读全文

posted @ 2018-12-06 20:06 猪猪🐷 阅读(107) 评论(0) 推荐(0)

2018年11月30日

549. Binary Tree Longest Consecutive Sequence II

摘要: Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree. Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are bot... 阅读全文

posted @ 2018-11-30 13:45 猪猪🐷 阅读(203) 评论(0) 推荐(0)

718. Maximum Length of Repeated Subarray

摘要: Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays. Example 1: Since a common subarray of A and B 阅读全文

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

662. Maximum Width of Binary Tree

摘要: Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar 阅读全文

posted @ 2018-11-30 07:32 猪猪🐷 阅读(116) 评论(0) 推荐(0)

2018年11月29日

890. Find and Replace Pattern

摘要: You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a permutation of letters p so that after replacing ev... 阅读全文

posted @ 2018-11-29 07:22 猪猪🐷 阅读(89) 评论(0) 推荐(0)

843: Guess the Word

摘要: This problem is an interactive problem new to the LeetCode platform. We are given a word list of unique words, each word is 6 letters long, and one wo 阅读全文

posted @ 2018-11-29 07:20 猪猪🐷 阅读(146) 评论(0) 推荐(0)

361. Bomb Enemy

摘要: Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
The bomb kills all the enemies in the same row an... 阅读全文

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

2018年11月27日

939. Minimum Area Rectangle

摘要: Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes. If 阅读全文

posted @ 2018-11-27 15:17 猪猪🐷 阅读(224) 评论(0) 推荐(0)

2018年11月9日

OOD 2 : design parking lot

摘要: public enum VehicleSize{ Compact(1); Large(2); // ? why use number private final int size; VehicleSize(int size){ this.size = size; } public int getSize(){ return size; ... 阅读全文

posted @ 2018-11-09 11:49 猪猪🐷 阅读(204) 评论(0) 推荐(0)

Ood : static

摘要: Ood : static https://www.geeksforgeeks.org/static-keyword-java/ When to use static variables and methods? Use the static variable for the property tha 阅读全文

posted @ 2018-11-09 11:49 猪猪🐷 阅读(121) 评论(0) 推荐(0)

OOD 3 (big class)

摘要: // builder pattern // some fields are mandatory., some of them are optional // hard to intisalize all the constructors to take care of all the cases // solution 1 : // so use setter/getters // ... 阅读全文

posted @ 2018-11-09 11:48 猪猪🐷 阅读(213) 评论(0) 推荐(0)

ood 4 (big class)

摘要: ODD4 棋牌类的 我己经晕了, 换个类型 public enum Suit{ Club; Diamond; Heart; Spade; } public class Card{ private int faceValue; // 1 for A, 11 for J, 12 for Q, 13 for K. or we can use enum here pr... 阅读全文

posted @ 2018-11-09 11:47 猪猪🐷 阅读(133) 评论(0) 推荐(0)

implement hash table

摘要: Implement hash table https://www.youtube.com/watch?v=shs0KM3wKv8&t=8s https://www.youtube.com/watch?v=KyUTuwz_b7Q https://www.geeksforgeeks.org/implem 阅读全文

posted @ 2018-11-09 11:46 猪猪🐷 阅读(168) 评论(0) 推荐(0)

874. Walking Robot Simulation

摘要: A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: -2: turn left 90 degrees -1: turn right 90 degrees 1 set = new Ha... 阅读全文

posted @ 2018-11-09 11:36 猪猪🐷 阅读(139) 评论(0) 推荐(0)

408. Valid Word Abbreviation

摘要: Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word",... 阅读全文

posted @ 2018-11-09 11:32 猪猪🐷 阅读(112) 评论(0) 推荐(0)

362. Design Hit Counter

摘要: Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made ... 阅读全文

posted @ 2018-11-09 11:31 猪猪🐷 阅读(126) 评论(0) 推荐(0)

524. Longest Word in Dictionary through Deleting

摘要: Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, retu... 阅读全文

posted @ 2018-11-09 11:28 猪猪🐷 阅读(147) 评论(0) 推荐(0)

392. Is Subsequence

摘要: 0 3 5 7 Prev = 4 Smallest larger or equal is 5 If prev = 8, return -1 阅读全文

posted @ 2018-11-09 11:25 猪猪🐷 阅读(143) 评论(0) 推荐(0)

409. Longest Palindrome

摘要: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example "Aa" is not consi... 阅读全文

posted @ 2018-11-09 11:05 猪猪🐷 阅读(108) 评论(0) 推荐(0)

792. Number of Matching Subsequences

摘要: Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of S. Example : Input: S = "abcde" words = ["a", "bb", "acd", "ace"] Output: 3 Explanation: Ther... 阅读全文

posted @ 2018-11-09 11:04 猪猪🐷 阅读(132) 评论(0) 推荐(0)

686. Repeated String Match

摘要: Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cdabcdab". R... 阅读全文

posted @ 2018-11-09 11:02 猪猪🐷 阅读(121) 评论(0) 推荐(0)

744. Find Smallest Letter Greater Than Target

摘要: 一开始这个规则没看到, Letters also wrap around. For example, if the target is target = 'z' and letters = ['a', 'b'], the answer is 'a'. 把规则都弄清楚后, 还是走例子, Given a 阅读全文

posted @ 2018-11-09 10:59 猪猪🐷 阅读(109) 评论(0) 推荐(0)

852. Peak Index in a Mountain Array

摘要: Let's call an array A a mountain if the following properties hold: A.length >= 3 There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[ 阅读全文

posted @ 2018-11-09 10:56 猪猪&#128055; 阅读(111) 评论(0) 推荐(0)

374. Guess Number Higher or Lower

摘要: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you whether the number is highe... 阅读全文

posted @ 2018-11-09 10:55 猪猪&#128055; 阅读(134) 评论(0) 推荐(0)

287. Find the Duplicate Number

摘要: 这个解法用 count 来 数 数组中一共有多少位在mid value 之前, 这样就不用 sort 这个array 了 如果本来有两个在前面, 但是 数出来三个, 就说明 多余的那个 就在前面, otherwise, 在后面 This solution is based on binary sea 阅读全文

posted @ 2018-11-09 10:53 猪猪&#128055; 阅读(118) 评论(0) 推荐(0)

54. Spiral Matrix

摘要: DescriptionHintsSubmissionsDiscussSolution Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], ... 阅读全文

posted @ 2018-11-09 10:49 猪猪&#128055; 阅读(141) 评论(0) 推荐(0)

118. Pascal's Triangle

摘要: DescriptionHintsSubmissionsDiscussSolution Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers dir... 阅读全文

posted @ 2018-11-09 10:48 猪猪&#128055; 阅读(130) 评论(0) 推荐(0)

60. Permutation Sequence

摘要: https://leetcode.com/problems/permutation-sequence/discuss/22507/%22Explain-like-I'm-five%22-Java-Solution-in-O(n) https://www.youtube.com/watch?v=xdvPD1IiyUM The set [1,2,3,...,n] contains a to... 阅读全文

posted @ 2018-11-09 10:46 猪猪&#128055; 阅读(112) 评论(0) 推荐(0)

256. Paint House

摘要: There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the h... 阅读全文

posted @ 2018-11-09 10:44 猪猪&#128055; 阅读(119) 评论(0) 推荐(0)

135. Candy

摘要: follow up:如何不使用extra space解决这道题 https://leetcode.com/problems/candy/solution/ Approach 4: Single Pass Approach with Constant Space Algorithm https://leetcode.com/problems/candy/discuss/42770/On... 阅读全文

posted @ 2018-11-09 10:43 猪猪&#128055; 阅读(123) 评论(0) 推荐(0)

496. Next Greater Element I

摘要: https://www.youtube.com/watch?v=KZhjUwuMC0Y You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's ... 阅读全文

posted @ 2018-11-09 10:42 猪猪&#128055; 阅读(151) 评论(0) 推荐(0)

503. Next Greater Element II

摘要: Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first gr... 阅读全文

posted @ 2018-11-09 10:41 猪猪&#128055; 阅读(149) 评论(0) 推荐(0)

96. Unique Binary Search Trees

摘要: 96. Unique Binary Search Trees https://leetcode.com/problems/unique-binary-search-trees/discuss/31666/DP-Solution-in-6-lines-with-explanation.-F(i-n)-G(i-1)-*-G(n-i) Given n, how many structurally... 阅读全文

posted @ 2018-11-09 10:40 猪猪&#128055; 阅读(130) 评论(0) 推荐(0)

459. Repeated Substring Pattern

摘要: Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Engl... 阅读全文

posted @ 2018-11-09 10:40 猪猪&#128055; 阅读(102) 评论(0) 推荐(0)

807. Max Increase to Keep City Skyline

摘要: In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts ca... 阅读全文

posted @ 2018-11-09 10:39 猪猪&#128055; 阅读(134) 评论(0) 推荐(0)

导航