2018年11月9日

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 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 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; 阅读(114) 评论(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; 阅读(131) 评论(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)

导航