摘要: 题意是计算a/b,其中a、b均为int,结果也要int。但是计算不允许使用乘法、除法、取模运算。 class Solution { public: // Divide two unsigned int once, using binary divide method. unsigned int unsigned_divide_on... 阅读全文
posted @ 2012-09-08 16:20 紫红的泪 阅读(1905) 评论(0) 推荐(0) 编辑
摘要: 题意是1-26对应于A-Z,这样一个数字字符串可以解码成只包含A-Z的字符串。例如,12可以解码成AB,也可以解码成L。这样12就有两种解码方式。实现numDecodings(string s)接受数字字符串,返回可以解码的方式数。 int check(char one) { return (one != '0') ? 1 : 0; } ... 阅读全文
posted @ 2012-09-08 11:08 紫红的泪 阅读(1970) 评论(0) 推荐(0) 编辑