There are a lot of interview problem based on the 1D-array, which is the one of the easiest "data structure".
But the problem about that simple data structure might not be that simple. Here is the summary of the problem about 1D-array.
Of course, most of them come from …
more ...在__为什么转置一个512x512的矩阵,会比513x513的矩阵慢很多?__一文中,作者引用了一个矩阵转置的例子,来讲解由于CPU cache的失效而带来的性能损失。
上面的文章对问题的解释与讨论都 …
more ...Simple and easy, solved by two lines of python code.
ls = filter(lambda y: y, map(lambda x: x.strip(), raw_input()[1:-1].split(",")))
print len(set(ls))
Brute force. Just enumerate the beginning and the end of the substring, and …
more ...This problem is from the book "Algorithm 4th edition" (Exersise 4.1.10)
There are N cities and M undirected roads between those cities. People can travel to any city along the roads.
One day, a war breaks out. Our cities are under attack! As we can't defend all …
more ...尽管80核心的浮点运算巨兽仍然遥不可及,多核处理器的时代已经到来。多核处理器的概念并非新鲜事物,在Power Macintosh 9500中就已经采用了多核处理器技术 …
more ...Trun x => X
or X => x
to make the number of 'x' is equal to the number of 'X'.
n = int(raw_input())
hamsters = [c for c in raw_input()]
sits = hamsters.count('x')
stands = hamsters.count('X')
if sits == stands:
print 0
print ''.join(hamsters)
else:
if sits > stands …
It has been months that I didn't participate in the contest on CF, now I'm back. :)
This round of contest makes me confused that the problem B and C is a little bit too twisted, if you can't catch the vital point, you will get a lot of WAs …
more ...For most time, we use malloc
or new
for memory allocation, which will get it on heap.
However, access memory on heap is not as effective as the memory on stack, because the heap is "free-floating region of memory". To the contrary, memory on stack is managed by CPU …
more ...