随笔分类 - Summary
Leetcode: Optimize Water Distribution in a Village && Summary: Union Find and Minimum Spanning Tree
只有注册用户登录后才能阅读该文。
Summary: curated List of Top 75 LeetCode Questions to Save Your Time
摘要:Facebook / Eng tech lead Dec 30, 2018 68 Comments Facebook / Eng tech lead Facebook / Eng tech lead Dec 30, 2018 68 Comments New Year Gift to every fe
阅读全文
Summary: Calculate average where sum exceed double limits
摘要:According to the highest vote in: http://stackoverflow.com/questions/1930454/what-is-a-good-solution-for-calculating-an-average-where-the-sum-of-all-v
阅读全文
Summary: How to calculate PI? Based on Monte Carlo method
摘要:refer to: http://www.stealthcopter.com/blog/2009/09/python-calculating-pi-using-random-numbers/ During my undergraduate degree I wrote a program in fo
阅读全文
Leetcode: LFU Cache && Summary of various Sets: HashSet, TreeSet, LinkedHashSet
摘要:referred to: https://discuss.leetcode.com/topic/69137/java-o-1-accept-solution-using-hashmap-doublelinkedlist-and-linkedhashset Two HashMaps are used,
阅读全文
Leetcode: Word Squares && Summary: Another Important Implementation of Trie(Retrieve all the words with a given Prefix)
摘要:Backtracking + Trie: referred to https://discuss.leetcode.com/topic/63516/explained-my-java-solution-using-trie-126ms-16-16 A better approach is to ch
阅读全文
Leetcode: Longest Substring with At Most K Distinct Characters && Summary: Window做法两种思路总结
摘要:我的做法:维护一个window,r移动到超出k distinct character限制是更新max,然后移动l使distinct character <=k; 这种做法更新max只发生在超出限制的时候,有可能永远都没有超出限制,所以while loop完了之后要补上一个max的更新 别人非常棒的做
阅读全文
Leetcode: Combination Sum IV && Summary: The Key to Solve DP
摘要:DP 解法: the key to solve DP problem is to think about how to create overlap, how to re-solve subproblems(怎么制造复用) Bottom up dp: Better Solution(Bottom-u
阅读全文
Leetcode: Sum of Two Integers && Summary: Bit Manipulation
摘要:转自https://discuss.leetcode.com/topic/49771/java-simple-easy-understand-solution-with-explanation/2,注意里面对于减法的讲解 have been confused about bit manipulati
阅读全文
Groupon面经Prepare: Sort given a range && Summary: Bucket Sort
摘要:首先是如何sort一个只有0和1的数组,要求inplace. follow up是告诉一个range,如何在O(N)时间内sort好 两个pointer可解 1 package Sorting; 2 import java.util.*; 3 4 public class InplaceSortin
阅读全文
Summary: Final Keyword
摘要:In this tutorial we will learn the usage of final keyword. final keyword can be used along with variables, methods and classes. We will cover followin...
阅读全文
Leetcode: Range Sum Query 2D - Mutable && Summary: Binary Indexed Tree
摘要:参考:https://leetcode.com/discuss/72685/share-my-java-2-d-binary-indexed-tree-solution Build binary indexed tree takes : O(mn*logm*logn) time, both upda
阅读全文
Summary: Merge Sort of Array && 求逆序对
摘要:常用算法(后面有inplace版本): 1 package ArrayMergeSort; 2 3 import java.util.Arrays; 4 5 public class Solution { 6 public int[] mergeSort(int[] arr) { 7 if (arr
阅读全文
Summary: Process & Tread
摘要:refer tohttp://www.programmerinterview.com/index.php/operating-systems/thread-vs-process/A process is an executing instance of an application. What do...
阅读全文
Leetcode: Range Sum Query - Mutable && Summary: Segment Tree
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by upda...
阅读全文
Leetcode: Number of Islands II && Summary of Union Find
摘要:Union Find Princeton's lecture note on Union Find in Algorithms and Data Structures It is a well organized note with clear illustration describing fro
阅读全文
Leetcode: Alien Dictionary && Summary: Topological Sort
摘要:There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words from the...
阅读全文
Leetcode: Graph Valid Tree && Summary: Detect cycle in undirected graph
摘要:This problem can be solved by using union find, reference this blog:https://segmentfault.com/a/1190000003791051 复杂度 时间 O(N^M) 空间 O(N) 思路 判断输入的边是否能构成一个
阅读全文