摘要:
Static Factory Methods v.s. Constructor Advantages to use Static Factory Methods 1. More descriptive - the name of the factory methods can explain mor 阅读全文
摘要:
1. Never return in a finally statement. If you return in a finally block then any Throwables that aren't caught will be completely lost. e.g. 2. If re 阅读全文
摘要:
1. What is the difference between The new ArrayList is an independent copy of the original one. Although you create the wrapper using Arrays.asList, i 阅读全文
摘要:
Refer http://www.jianshu.com/p/2b5a9bdcd25f https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html Review Access Level In General Abstract C 阅读全文
摘要:
1. Preorder Tree Traversal 2. Inorder Tree Traversal 3. Postorder Tree Traversal 阅读全文
摘要:
Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adja 阅读全文
摘要:
i & -i = i 最低位的 1 所表示的值 i 单数: i & -i = 1 i 双数: i = 2^k1 +...+ 2^kn (k1 <...<kn) i & -i = 2^k1(负数二进制表达 = 其绝对值的二进制表达 + 1) 阅读全文
摘要:
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are give 阅读全文
摘要:
Reference : https://leetcode.com/discuss/72701/here-10-line-template-that-can-solve-most-substring-problems 3. Longest Substring Without Repeating Cha 阅读全文
摘要:
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num 阅读全文
摘要:
Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is "ece" whi 阅读全文
摘要:
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
摘要:
Given an array of integers, every element appears three times except for one. Find that single one. Similar: 136. Single Number 260. Single Number III 阅读全文
摘要:
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you 阅读全文
摘要:
Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm s 阅读全文
摘要:
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements 阅读全文
摘要:
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
摘要:
Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
摘要:
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
摘要:
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
摘要:
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except 阅读全文
摘要:
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t 阅读全文
摘要:
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文
摘要:
一个矩阵,求最长连续的序列长度 [1 2 3 4 5 6 7 8 9] 我的解法时用dfs遍历矩阵,如果便利过的元素就标记为false,不再遍历。 邻居 就是上下左右 e.g. 1 2 3 6 5 4 -> 7 7 9 8 =================== 5 7 9 1 2 3 -> 3 4 阅读全文
摘要:
If you need to maintain a list of objects that are sorted and unique & if you need to be able to quickly insert and retrieve objects to and from this 阅读全文
摘要:
方法 时间复杂度 空间复杂度 Stable 冒泡排序(Bubble Sort) O(n) — O(n^2) O(1) yes 选择排序(Selection Sort) O(n^2) — O(n^2) O(1) no 插入排序(Insertion Sort) O(n) — O(n^2) O(1) ye 阅读全文
摘要:
http://www.geeksforgeeks.org/rearrange-a-string-so-that-all-same-characters-become-at-least-d-distance-away/ Given a string and a positive integer d. 阅读全文
摘要:
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i 阅读全文
摘要:
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
摘要:
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文