摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8模拟加法,注意最后加法结束时可能有进位 阅读全文
posted @ 2012-10-27 19:32 chkkch 阅读(1469) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".这题用数组来做可能更简单,但考虑到可能面试的时候要求不能开额外的数组,就只能对string操作了。最主要的是把进位这部分写对。 1 class Solution { 2 public: 3 string addBinary(string a, string b) { 4 // Start typing your C/C++ solu 阅读全文
posted @ 2012-10-27 19:23 chkkch 阅读(4169) 评论(0) 推荐(1) 编辑
摘要: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)The solution set must not contain duplicate triplets. For e... 阅读全文
posted @ 2012-10-27 19:12 chkkch 阅读(1108) 评论(0) 推荐(0) 编辑
摘要: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d)The solution set must not contai 阅读全文
posted @ 2012-10-27 18:21 chkkch 阅读(3471) 评论(0) 推荐(0) 编辑
摘要: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.For example, given array S = {-1 2 1 -4}, and target = 1.The sum that is closest to th 阅读全文
posted @ 2012-10-27 18:03 chkkch 阅读(5705) 评论(1) 推荐(0) 编辑
摘要: 为了这次的比赛可谓拼劲全力,耗时4个月,依然有许多值得改进的地方。从北京回来了,命题组三等奖。下载:作品简介最短路径并行算法论文Google Code: http://code.google.com/p/cuda-shortest-path/ 阅读全文
posted @ 2011-12-05 17:58 chkkch 阅读(787) 评论(2) 推荐(0) 编辑
摘要: 终于把《Android应用开发》的第一个例子给编译成功了,太不容易了。几经辗转到国人写的《Google Android开发入门与实战》,发现是本烂书,只会堆代码,什么都没讲清楚。还是回到了这本OReilly,其中最诡异的是一个override问题,终于参考了这篇博文解决,主要是把Java Compiler设为1.6。其他的问题可以搜下网上的。点击这里,可编译版本。终于开始Android之路,目标是明年的QQ比赛。 阅读全文
posted @ 2011-11-03 20:36 chkkch 阅读(894) 评论(4) 推荐(0) 编辑
摘要: 这几个星期一直在搞摩根的竞赛,终于是结束了。但不够淋漓尽致,原因有很多,最主要的应该是之前的CUDA比赛搞得筋疲力尽了,而这些天导师又追杀论文。最后,放出比赛的Final Report吧。也没怎么好好的改,只是用word生成了pdf,之前的CUDA报告用的是latex写的,等CUDA比赛结束了,连着代码一并放出吧。Paper:Final ReportGoogle Code: Options Pricing Model Project 阅读全文
posted @ 2011-10-30 20:14 chkkch 阅读(1319) 评论(0) 推荐(1) 编辑
摘要: 最近收到THU的同学回复:第6关似乎应该是链表。我之前也很奇怪怎么最后一关会这么简单。于是找来最高难度的phase_6版本挑战一下。 phase_6的反汇编也确实够长了(差不多两页A4)。刚开始,真有点不知从何下手。先大致浏览一遍,唯一的印象是这段代码中跳转语句达到了12个,仅仅是这一条就会晕头转向了。 根据以往的经验,首先就是选出那些不该执行的语句(explode_bomb)。如图所示,黄线标出了引爆点。另外,既然跳转这么多,那就先来看看跳转,理出个大体结构。可以看到代码中跳转分成了两大类:1)条件跳转。2)直接跳转。而进一步分析,有些条件跳转是和call explode_bomb相关的,而 阅读全文
posted @ 2011-06-27 17:01 chkkch 阅读(7406) 评论(3) 推荐(3) 编辑
摘要: “你的时间有限,所以不要为别人而活。不要被教条所限,不要活在别人的观念里。不要让别人的意见左右自己内心的声音。最重要的是,勇敢的去追随自己的心灵和直觉,只有自己的心灵和直觉才知道你自己的真实想法,其他一切都是次要。 ——史蒂夫·乔布斯” CSAPP的第五章“优化程序性能”,从机器底层的角度阐述了如何去优化。说实话,这章就应该撕掉,然后扔进垃圾桶。真是越看越火大,越看越觉得扯淡。要是你想成为一个三流程序员,就应该一丝不苟地按照书中的做。 如果你写了个程序,觉得它太慢。那么你可以花半年去优化它,也可以跑去找小姑娘玩半年回来,然后更强大的硬件就会让你的程序更快。 优化仅仅是在万不得已之时才 阅读全文
posted @ 2011-06-24 22:11 chkkch 阅读(21985) 评论(29) 推荐(8) 编辑