11 2016 档案

摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2016-11-20 10:58 yrwang 阅读(171) 评论(0) 推荐(0)
摘要:Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process 阅读全文
posted @ 2016-11-10 01:58 yrwang 阅读(139) 评论(0) 推荐(0)
摘要:Problem: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the f 阅读全文
posted @ 2016-11-03 08:51 yrwang 阅读(141) 评论(0) 推荐(0)
摘要:最原始的方法:先排序,然后从头查找。若nums[i] = nums[i] + 1则为一对相同的数,i = i + 2,继续判断。若nums[i] != nums[i] + 1,则输出nums[i]。需注意不要越界! 通过参考别人的解题报告发现,可以使用异或运算:对所有元素做异或运算,其结果为那个出现 阅读全文
posted @ 2016-11-02 08:08 yrwang 阅读(116) 评论(0) 推荐(0)
摘要:此题为技巧题,需知道Nim Game的Wining Strange,即在自己的局中,如果剩余数目为4的倍数,则不可能取胜。因此检测N是否为4的倍数即可。Background参见http://www.cdf.toronto.edu/~ajr/270/probsess/03/strategy.html 阅读全文
posted @ 2016-11-02 05:45 yrwang 阅读(184) 评论(0) 推荐(0)