- 博客(26)
- 收藏
- 关注
原创 Redirect stdio in Java and C, 在Java和C代码中重定向输出。
Situation:Printing is a major tool for debug at most time for most programmers, I belive
2014-04-10 11:08:30
877
原创 LeetCode_Single Number II
My understanding of Leetcode 'Single Number II'
2013-10-05 17:24:08
1004
4
原创 Leetcode_Populating Next Right Pointers in Each Node II
Question link: http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could
2013-10-04 20:20:10
533
原创 CJ_China_Campus_Test_Summary
This is my own summary of the contest, mainly to give myself advice on how to make me faster on the next contest.1. Bad horse. Situation: This is a simple graph traversal problem. I used 34 mi
2013-09-14 11:42:16
698
原创 Longest Substring using dp and thinking on dp
Problem:find the longest consecutive substring of two string S, K. Use DP.Solution: Matrix: m[m][n] m[i][j] = 0, if Si != Kj; m[i][j] = m[i-1][j-1] + 1 if Si == Kj;
2013-09-06 23:37:34
530
原创 One way to improve running time
For most puzzles, if we can understand what the question says, we will be able to give a direct answer. But that simple answer is always not so good in terms of efficiency.Sometimes this is because
2013-08-28 22:47:57
565
原创 TADM_3-15
Problem:Design a data structure that allows one to search, insert, and delete an integerX in O(1) time (i.e. , constant time, independent of the total number of integersstored). Assume that 1 ≤
2013-08-28 22:24:41
651
原创 TADM_3-11
Problem: Suppose that we are given a sequence of n values x1, x2, ..., xn and seek to quickly answer repeated queries of the form:given i and j, find the smallest value in xi, ...., xj.1. Desig
2013-08-28 21:36:55
1707
原创 原来C语言也有正则表达式的库
这几天开始在Hackerrank上边刷题目玩。做到正则表达式专题的时候,自己提交成功之后,可以看到别人提交的答案。于是忍不住看了下一个人用C语言做的答案。好奇怎么C语言也能使用正则表达式。比较牛逼的是,C语言的正则表达式可以帮你找出子模式。C语言的正则表达式的说明在这个地方:http://linux.die.net/man/3/regexec总体用法跟Java的差不多。
2013-08-19 15:45:41
2444
原创 9.2-3 Iterative version of Randomized-Select
9.2-3Write an iterative version of RANDOMIZED-SELECTAnalyse:For this the original recursive algorithm, the recursion doesn't need to remember the intermediate information, ie. there is no co
2013-07-29 10:20:11
933
原创 9.1-2 Find the second smallest of n elements.
9.1-1Show that the second smallest of n elements can be found with n + lg n - 2comparisons in the worst case. (Hint: Also find the smallest element.)I thinked about it for some time and
2013-07-29 10:07:26
741
1
原创 6-3 Young tableaus
6-3 Young tableausAn m × n Young tableau is an m × n matrix such that the entries of each row arein sorted order from left to right and the entries of each column are in sorted orderfrom top to
2013-07-17 17:46:36
1553
原创 6.5-9 merge k sorted lists into one sorted list with O(n lg k)
6.5-9Give an O.n lg k/-time algorithm to merge k sorted lists into one sorted list,where n is the total number of elements in all the input lists. (Hint: Use a minheapfor k-way merging.)So
2013-07-17 12:30:55
2295
原创 6.5-8 Heap-Delete
6.5-8The operation HEAP-DELETE.A; i / deletes the item in node i from heap A. Givean implementation of HEAP-DELETE that runs in O.lg n/ time for an n-elementmax-heap.Solution1. Find the
2013-07-17 12:19:46
896
原创 6.5.6 Three Assignment to 1
6.5.6Each exchange operation on line 5 of HEAP-INCREASE-KEY typically requiresthree assignments. Show how to use the idea of the inner loop of INSERTIONSORTto reduce the three assignments down t
2013-07-17 11:54:42
2532
原创 5.3-6 PERMUTE-BY-SORTING, if two or more priorities are identical
Problem 5.3-6Explain how to implement the algorithm PERMUTE-BY-SORTING to handle thecase in which two or more priorities are identical. That is, your algorithm shouldproduce a uniform random per
2013-07-10 18:03:19
1897
原创 5.2-2 What is the probability that you hire exactly twice
In HIRE-ASSISTANT, assuming that the candidates are presented in a random order, what is the probability that you hire exactly twice?AnlysisObservation 1: You have to hire the first person int
2013-07-10 13:52:26
2138
原创 这两天实现了两个可滑动控件的嵌套。
此处先留一个占位的文章~~以后再来填上~问题是:当两个可滑动View嵌套的时候,1. 出来的布局就会难以用xml控制。2. 滑动事件也会乱套。解决方案:
2013-06-27 16:27:52
813
原创 团队任务等待系统
在一个团队中,经常会有某某人等待某某人完成某个事情之后,等待某个人通知的问题。特点,这种等待关系可能会快速的变化,可能前后只有十五分钟的时间。如果对于一个比较大的部分,比如两个人相差20m。如果这种等待比较多的话,可能比较浪费时间。设想,一个小系统可以快速的输入等待事件,比如说A等待B完成一个事情,Aj就在系统里边常见等待事件,B就能知道A在等他完成什么事情。这么想的话
2013-06-25 11:11:30
535
原创 通过打印读代码
总结如下:1. 在读代码的时候,你肯定会带代码中的某些变量的变化规律有某种猜想。2. 那么就把这些有猜想的变量打印出来,以验证自己的猜想,从而把这种猜想变成很强的事实。3. 将刚刚的猜想清零。4. 这个时候你就又会有其他的猜想,于是回到第二步。从而摸清大部分变量的变化规律,以帮助读懂代码。当然,我还是觉得读代码最好还是要找到代码相关的文档或注释,先弄清楚这个代码是干
2013-06-24 11:16:17
572
原创 对ACM的一点看法。
我自己没有进行过ACM的训练以及比赛。在这方面也比较欠缺,从本科到现在也是主要把时间放在做工程上边来了。其实心里边很长时间以来还是窃以为搞ACM的人挺厉害的。但是随着时间的推移,慢慢的我有了一些自己的见解,也就是所谓的吃不到葡萄说葡萄酸的自我安慰吧。哈哈,这么说当然是怕被别人喷了~~从我的经历和理解来说,本文只是为了记录。 1. ACM是可以训练的。 ACM作为
2013-06-02 21:34:59
1020
1
原创 Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,
2013-06-02 21:19:16
458
原创 Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region .For example,X X X XX O
2013-05-31 01:48:13
407
原创 测试CSDN的格式用。
int a=0;for(int i=0; i<100; i++){ a++;}就像我写程序喜欢自己写个小demo测一测一样,这里弄一个文章,专门用来测试csdn博客各种格式的使用。
2013-05-29 17:44:50
354
原创 单例的Double check问题和CPU动态调度共存时的线程安全问题。
改编自《程序员的自我修养》主要是为了记录和整理一下自己的思路。一种典型的单例的实现方式是:volatile T* pInstance = NULL;T* getInstance(){ if(!pInstance){ lock(); if(!pInstance){ T* temp = new T(); pInstance = temp; } unlock(
2013-05-29 17:38:17
1014
1
原创 决定在csdn开始写自己的博客。
决定在csdn写自己的博客。主要是技术的具体和抽象的总结,对生活和所谓的“道”的思考。之前在百度空间零零碎碎的做了一些记录~~http://hi.baidu.com/cheetach_jiang
2013-05-17 09:04:19
500
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人