02 2016 档案
M面经prepare: Shuffle a deck
摘要:设计一个shuffle card 用了java. Random Class 1 package Random; 2 import java.util.*; 3 4 public class Solution { 5 static int cardNum = 10; 6 public int[] sh
阅读全文
M面经Prepare: Find integer Average of 2 integers.
摘要:The definition of integer average is the highest smaller integer if average is floating point number. Also the condition if that they can not use any
阅读全文
M面经Prepare: Positive-Negative partitioning preserving order
摘要:Given an array which has n integers,it has both positive and negative integers.Now you need sort this array in a special way.After that,the negative i
阅读全文
M面经Prepare: Delete Words Starting With One Character
摘要:给定一个char array, 这个array是一个句子,然后给定一个字母,把这个array里面带有这个字母开头的单次删掉,操作是要求in place. 检测 array[i]==' ' && i<array.length-1 && array[i+1]==target,这种情况,设置j从i+1开始
阅读全文
Lintcode: Subtree
摘要:You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of
阅读全文
Leetcode: Reconstruct Itinerary
摘要:refer to Recursion https://leetcode.com/discuss/84702/share-my-solution and Iteration https://leetcode.com/discuss/84706/share-solution-java-greedy-st
阅读全文
Groupon面经:Find paths in a binary tree summing to a target value
摘要:You are given a binary tree (not necessarily BST) in which each node contains a value. Design an algorithm to print all paths which sum up to that val
阅读全文
Groupon面经Prepare: Max Cycle Length
摘要:题目是遇到偶数/2,遇到奇数 *3 + 1的题目,然后找一个range内所有数字的max cycle length。对于一个数字,比如说44,按照题目的公式不停计算,过程是 44, 22, 11, 8, 9 ,1(瞎起的),从44到1的这个sequence的长度,叫做cycle length。然后题
阅读全文
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
阅读全文
Lintcode: Expression Evaluation (Basic Calculator III)
摘要:Given an expression string array, return the final result of this expression Have you met this question in a real interview? Yes Example For the expre
阅读全文
Lintcode: Count of Smaller Number
摘要:Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) and an query list. For each query, give you
阅读全文
Lintcode: Interval Sum II
摘要:Given an integer array in the construct method, implement two methods query(start, end) and modify(index, value): For query(start, end), return the su
阅读全文
Lintcode: Interval Sum
摘要:Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers [start, end]. For each
阅读全文
Lintcode: Interval Minimum Number
摘要:Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers [start, end]. For each
阅读全文
Lintcode: Segment Tree Query II
摘要:For an array, we can build a SegmentTree for it, each node stores an extra attribute count to denote the number of elements in the the array which val
阅读全文
Lintcode: Segment Tree Modify
摘要:For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in this node's interval. Implement a modify function wit
阅读全文
Lintcode: Segment Tree Query
摘要:For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each node stores an extra attribute m
阅读全文
Leetcode: Verify Preorder Serialization of a Binary Tree
摘要:One way to serialize a binary tree is to use pre-oder traversal. When we encounter a non-null node, we record the node's value. If it is a null node,
阅读全文
Lintcode: Segment Tree Build
摘要:The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval. start and end are both i
阅读全文
Lintcode: Matrix Zigzag Traversal
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in ZigZag-order. Have you met this question in a real intervie
阅读全文