- 博客(27)
- 资源 (1)
- 收藏
- 关注
原创 Zookeeper 使用
下载安装 zookeeper wget http://ftp.wayne.edu/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz tar xvf zookeeper-3.4.6.tar.gz export JAVA_HOME=`/usr/libexec/java_home -v 1.7` cp conf/zoo_sa
2015-06-08 13:48:39 770
原创 Dynamic Programming Solvable Problem
1. Knapsack, n items, put into size W bag, maximize the item value in the bag 1.1 n items put into 2 bag, bag size as W1, and W2 1.2 select at most k item from n, put them in the bag size
2013-10-18 11:45:30 589
原创 C++ memory management
1. vector 1. 1 After vector is allocated, the memory it occupies is not freed until destructor is called, even if v.clear() is called. To explicitly deallocate this piece of memory, use this tri
2013-10-13 11:02:31 498
原创 Summarize of network protocol in c
Internet Addr in_port_t: uint16_t, 16 bits for ports socket * create new socket int socket (int namespace, int style, int protocol) style: SOCK_STREAM or SOCK_DGRAM * bind a namesp
2013-10-06 13:52:05 531
原创 Understanding Memcached Source Code
I am trying to learn how memcached works by reading its testcase step by step ------------------------------------------------------------------------------------------------------------------------
2013-10-04 14:19:08 686
原创 Memcached and libmemcached Installation on Solaris 11
It seems possible to install memcached using Solaris pkg: #pkg list -a memcached service/memcached (or see http://pkg.oracle.com/solaris/release/en/catalog.shtml) However, since I may want t
2013-09-30 14:05:45 1654
原创 How to use Compiler
GNU: gcc: g++: Sun: cc: 1. Memory model, -m64 flag indicate 64 bit memory model, otherwise, could not access more than 2 GB memory space cc -m64 -g mem_test.c CC:
2013-09-29 07:13:20 495
原创 Word Ladder I
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediat
2013-06-10 06:08:01 489
原创 LeetCode: Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You ma
2013-06-06 14:22:01 621
原创 LeetCode: Binary Tree Inorder Traversal, Morris In Order Traversal
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive sol
2013-06-02 15:39:55 707
原创 LeetCode: Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc",
2013-05-29 11:18:43 852
原创 LeetCode: Unique Binary Search Trees II, Dynamic Programming
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1
2013-05-23 12:56:13 883
原创 LeetCode: Unique Binary Search Trees, Dynamic Programming
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1
2013-05-23 12:02:08 824
原创 LeetCode: Scramble String, a naive recursion solution
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr
2013-05-20 14:07:02 1157
原创 LeetCode: Largest Rectangle in Histogram, a naive solution
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of each bar
2013-05-15 14:25:02 604
原创 LeetCode: Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BAN
2013-05-11 11:19:14 495
原创 Set Matrix Zeros
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight forward solution using O(mn) space is probably a b
2013-05-09 14:32:51 478
原创 LeetCode: Edit Distance of Two Words
Edit Distance of the Two WordsGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 opera
2013-05-09 13:29:18 568
原创 LeetCode: N Queens II
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. a DFS search will be exponential increase in terms of N. B
2013-04-24 10:41:37 605
原创 use map<key, val> in C++, solve LeetCode Anagrams 240 ms pass large test set
Anagrams Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. The basic idea is easy. From the definition of anagrams, we just n
2013-04-21 16:22:04 935
原创 External Merge Sort, time complexity analysis
The time complexity of Merge Sort is nlogn. How about the external merge sort? 1. One pass external merge sort step 1. break N data to k groups, each group has N/k data, complexity is N/klog(N/
2013-04-19 12:17:46 2065
原创 LeetCode: First Missing Positive
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses consta
2013-04-15 16:00:47 521
原创 LeetCode: Combination Sum II
Again, similar as the previous one, this combination sum could also be solved by DFS http://blog.csdn.net/u010204902/article/details/8803342 How to make sure that the result is unique? We nee
2013-04-15 15:43:02 644
原创 LeetCode: Combination Sum non recursive
The basic idea, shown in the previous blog http://blog.csdn.net/u010204902/article/details/8803342 is to use DFS I tried to use non-recursive method to do the DFS. I need to maintain a st
2013-04-15 15:16:43 1272
原创 LeetCode: Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited
2013-04-15 13:02:37 1276
原创 A Fast Sudoku Solver: LeetCode Problem
This is an efficient and fast solver for Sudoku problem. I passed the large test within 24ms. The problem is below: Write a program to solve a Sudoku puzzle by filling the empty cells.
2013-04-15 07:01:36 677
原创 LeetCode Sudoku Solver
56 ms 过large test 基本算法,有三个数组,分别记录每一行,每一列,每一个方块里面被填了的数,例如,如果第1行里,1已经被填了,那么 row[0][0] = 1, 这样,可以很快的测试对于board[i][j], 数字r是否可以填 if(row[i][r] == 0 && col[j][r] == 0 && square[i/3*3+j/3][r] == 0)
2013-04-15 05:51:37 863
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人