摘要: /* Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100 */ class Solution { public: string add 阅读全文
posted @ 2016-03-10 11:42 向日葵的祈愿 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 摘自:《啊哈算法》 我们要用1, 2, 5, 12, 7, 17, 25, 19, 36, 99, 22, 28, 46, 92来建立最小堆,并且删除最小的数,并增加一个数23 如何建立这个堆: //建堆 n = 0; for (int i = 1; i <= m; i++) { n++; h[n] 阅读全文
posted @ 2016-03-10 10:10 向日葵的祈愿 阅读(36963) 评论(0) 推荐(3) 编辑
摘要: 筛法计算素数: class Solution { public: int countPrimes(int n) { vector<bool> isprime(n, true); isprime[0] = false; isprime[1] = false; for (int i = 2; i < s 阅读全文
posted @ 2016-03-10 00:55 向日葵的祈愿 阅读(217) 评论(0) 推荐(0) 编辑