- 博客(16)
- 收藏
- 关注
原创 Balanced Partition of Array
Given an array which contains random positive integers, divide the array into two parts which has the smallest diff sum, return the smallest diff sum.This problem is solvable using dynamic programmi
2016-07-27 12:32:47 517
原创 LeetCode 375. Guess Number Higher or Lower II
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number I pi
2016-07-26 03:51:16 567
原创 374. Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is h
2016-07-25 23:47:02 223
原创 LeetCode 366. Find Leaves of Binary Tree
Given a binary tree, find all leaves and then remove those leaves. Then repeat the previous steps until the tree is empty.Example:Given binary tree 1 / \ 2 3
2016-07-25 23:29:15 300
原创 Maximum array distance Sum
Question: Given an array, find the maximum array distance sum. Array distance sum is defined as below. For any 0 For example, Given array {0, 2, -1}A[0][0] = 0, A[0][1] = 3, A[0][2] = 1; A[1][1] =
2016-07-25 12:46:31 223
原创 Dynamic Programming series
DP is absolutely the best way to category levels of programming..... and it is always the favourite questions being asked by FB or Google.1: Entry Level DP problem. /* A sequence of numbers i
2016-07-21 07:08:54 284
原创 TODO: house robber IIII
TODO: when rob one, the neighbour explored, get the max rob value.
2016-07-20 11:27:42 240
原创 TODO: System design a recommendation system
TODO: design a recommendation system.
2016-07-18 10:40:43 291
原创 Shuffle related problem.
Shuffle is quite a frequently asked question in interviews. The most famous one is shuffle a deck of cards.Peiyush Jain, 2004 published a paper "A simple in-place Algorithm for in-Shuffle". However
2016-07-18 09:59:05 588
转载 Haffman Encoding and Decoding
Read this blog and it seems this is a quite decent interview question. Haffman encodingHaffman encoding is a classic way to encode characters. It encodes characters according to building an optimis
2016-07-18 06:27:49 288
原创 Find Closet Pairs -- To be continue
1: Find closet pair number in an given array2: Find closet pair of points in an array of given points.3: Given a set of triangles, find the most overlapped points. (TODO: Will update them on July
2016-07-09 12:00:42 358
原创 Subarray Sum to the given target value
Question: check if there is a subarray sum equals to the given target.This question should ask for clarifications. Whether the inputs are all positive, or it has negative numbers.1: If all the num
2016-07-07 06:13:00 537
原创 Primes Product
Maybe think about how to solve it iteratively??#include "header.h"using namespace std;void primeProduct(vector& nums, vector& res, int product, int pos) { if(pos > nums.size()) { return;
2016-07-07 02:15:08 296
原创 Random Number Series Questions
This webpage gives a perfect solution to generate K random numbers from given N size array: http://www.geeksforgeeks.org/reservoir-sampling/However, there are a varieties of related questions.1: i
2016-07-06 07:59:24 241
原创 Next Larger Value in BST
This question need some clarification of the TreeNode structure. Suppose the given TreeNode struct is as following:Struct TreeNode {int val;TreeNode* left;TreeNode* right;TreeNode(int v) :
2016-07-06 04:41:31 280
原创 K consecutive maxSum
// given an array, find n consecutive number which forms the largest sum.#include "header.h"using namespace std;int maxConsecutive(vector& array, int n) { if(n <= 0) return 0; vector dp(array.
2016-07-05 11:58:04 247
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人