注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
写点啥回馈地里吧~~从这里收益不少,虽然不知道onsite结果如何,估计挂了?因为只有三轮,但是其中两轮都妥妥的顺利通过无bug,剩下一轮有一题没搞清楚面试官的意思,是关于hash collision的。大家回去看看基本概念,关于啥是linear hashing,quatratic hashing啥的。这里是我搜集的之前地里面试总结,有些leetcode有原题,有些我自己根据要求写的代码。总之不太难,大家加油
有米捧个米场,哈哈
zillow Median of Two sorted Arrays
Product of Array Except Self
Question: A solution consists of four balls from a set of four different colors. The user tries to guess the solution.
If they guess the right color for the right spot, record it as being in the correct 'Location'. If it's the right color, but the wrong spot, record it as a correct 'Color'. For example: if the solution is 'BGRR' and the user guesses 'RGYY' they have 1 'Location' and 1 'Color'. A correct solution would be 4 'Location' and 0 'Color'. Bulls and Cows
How would you discover a memory leak in a software product that contains thousands of lines?
You are given an array of integers and a sum. Find all pairs of integers that equal that sum. Two sum
Factorial Trailing Zeroes
Given a 2^31 x 2^31 tic tac toe board, describe how you would store the state of the game to check if there is a winner.
Maximum Subarray
Find all subsets of a set
Swap nodes in pairs in a linked list
Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Tree Find the Least Common Ancestor given two nodes of a binary tree. The nodes each have a reference to their parent node and you do not have the root node of the tree ?????????????????????????????????? public Node LCA(node A, node B){ if(height(A) > height(B)){ return LCA(B, A); } node t1 = A; node t2 = B; while(t1 != t2){ if(t2.parent == null){ if(t1.parent == null){ return null; }else{ t1 = t1.parent; } }else{ t2 = t2.parent; } } return t1; }
private int height(node A){ int count = 0; while(A.parent != null){ count++; A = A.parent; } return count; }
class Node { int val; Node parent; Node(int x){ val = x; } }
Determine if two rectangular are overlapped //check两个rectangle是否重叠 public class overlapRectangle { public static boolean check(Node topLeftA, Node topLeftB, Node bottomRightA, Node bottomRightB){ //左右关系,用x if(bottomRightA.x <= topLeftB.x || bottomRightB.x <= topLeftA.x){ return false; } //上下关系,用y if(topLeftA.y <= bottomRightB.y || topLeftB.y <= bottomRightA.y){ return false; }
Collections.sort(count_map, new Comparator<Map.Entry<List<Integer>, Integer>>{ public int compare(Map.Entry<List<Integer>, Integer> a, Map.Entry<List<Integer>, Integer> b){ return (b.getValue()).compareTo(a.getValue); } });
int i = 0; List<Integer>[] result = new ArrayList<Integer>[10]; for(Map.Entry<List<Integer>, Integer> entry : count_map){ result[i++] = entry.getKey(); if(i == 10){ break; } } } return result; }
class Log{ date time; int userId; int pageId; public Log (date time, int userId, int pageId){ this.time = time; this.userId = userId; this.pageId = pageId; } }
fibonacci implementation 求那个斐波那契数列, 刚开始就写了简单的递归,然后他说给个index,是让返回这个数列所有斐波那契数的和。 只好在写个函数,把每个斐波那契数算出来,加入到一个arraylist里面,再去扫一遍arraylist加到一起。然后问怎么优化,就把算斐波那契数的函数里面改用DP做
判断一个node 是否是另一个 node 的 child 很简单一个 DFS 搞定 ?????????????????????????????
Reverse Integer, 像这样:int reverse(1234), 返回4321
if (ret >= (Integer.MAX_VALUE - num % 10) / 10 && isPositive || ret >= (Integer.MAX_VALUE - num % 10 + 1) / 10 && !isPositive) { throws new Exception; } I miss the edge case where you should check for max integer input, basically if input is larger then Max integer, the function should throws NumberFormatException
|