01 2017 档案
FG面经: Interval问题合集
摘要:O(N) solution: 两个interval overlap条件: interval1.end >= interval2.start && interval1.start <= interval2.end 问:一个query数在不在已经加入的区间? 如果interval是sorted, 就可以
阅读全文
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
阅读全文
Pocket Gem OA: Log Parser
摘要:涉及到处理Date, 以及STDIN from a file 处理Date可以用SimpleDateFormat这个class static Date parseTime(String timeStr) { Date time = new Date(); DateFormat dft = new S
阅读全文
Leetcode: Sliding Window Median
摘要:方法1:Time Complexity O(NK) 暂时只有两个Heap的做法,缺点:In this problem, it is necessary to be able remove elements that are not necessarily at the top of the heap
阅读全文
Leetcode: Number Complement
摘要:Better solution: Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int va
阅读全文
FB面经 Prepare: Even Tree
摘要:我觉得题中应该再加上一个条件,就是guarantee是能够分割的,不然没法做. 如果总node总数是奇数的话, 怎么删都没法保证所有的子树是even number,所以这题的前提是node总数为偶数? 网上看到别人的很好的解法: 特别是用iterator.next()以后用iterator.remo
阅读全文
FB面经 Prepare: All Palindromic Substrings
摘要:Spread from center: Like LC 5: longest palindromic substring
阅读全文
FB面经 Prepare: Largest Island
摘要:Find largest island in a board 1 package fb; 2 3 public class LargestIsland { 4 public int findLargestIsland(int[][] board) { 5 if (board==null || board.length==0 || board[0].le...
阅读全文
FB面经 Prepare: Task Schedule
摘要:tasks has cooldown time, give an input task id array, output finish time input: AABCA A--ABCA output:7 1 package fb; 2 3 import java.util.*; 4 5 public class Scheduler { 6 7 pub...
阅读全文
Leetcode Articles: Insert into a Cyclic Sorted List
摘要:Solution:Basically, you would have a loop that traverse the cyclic sorted list and find the point where you insert the value (Let’s assume the value b
阅读全文
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
阅读全文
U家面试prepare: Serialize and Deserialize Tree With Uncertain Children Nodes
摘要:The method to serialize is like this: (1(2)(3(5)(6))(4(7))) if '(', right shift 1 position to the start of the number, use while loop to find the end
阅读全文