链接: https://leetcode.com/problems/reverse-bits/
此题的关键是预先将1
class Solution {
public:
Solution(){
unsigned int i = 0;
unsigned int j = 1;
for(; i < 32; i++)
a[i] = (j<<(31-i));
}
...
分类:
其他好文 时间:
2015-04-01 20:01:40
阅读次数:
126
链接:https://leetcode.com/problems/number-of-1-bits/
此题关键是如何判断一个数字的第i为是否为0 即: x& (1
class Solution {
public:
int hammingWeight(uint32_t n) {
int count = 0;
for(int i = 0; i < 32; ...
分类:
其他好文 时间:
2015-04-01 20:01:26
阅读次数:
122
Python 3.3.5Debian 3.12One thing I found weird is using the following code is that the input I entered isn't displayed, even after I terminate the scr...
分类:
编程语言 时间:
2015-04-01 14:53:11
阅读次数:
126
题目链接:
https://leetcode.com/problems/substring-with-concatenation-of-all-words/
参考链接:
http://www.w2bc.com/Article/14500
思路:
题目大意为,给定一个字符串S和一个字符串数组L,L中的各字符串长度均相等。找出S中所有的子串,这些子串恰好包含L中所有字符各一次,返...
分类:
其他好文 时间:
2015-04-01 11:31:20
阅读次数:
146
All submissions for this problem are available.Read problems statements in Mandarin Chinese and Russian.This problem's statement is really a short on....
分类:
其他好文 时间:
2015-03-31 22:09:45
阅读次数:
223
https://leetcode.com/problems/copy-list-with-random-pointer/A linked list is given such that each node contains an additional random pointer which cou...
分类:
其他好文 时间:
2015-03-31 21:58:01
阅读次数:
112
原题链接:http://oj.leetcode.com/problems/unique-binary-search-trees/这道题要求可行的二叉查找树的数量,事实上二叉查找树能够随意取根,仅仅要满足中序遍历有序的要求就能够。从处理子问题的角度来看,选取一个结点为根,就把结点切成左右子树,以这个结...
分类:
其他好文 时间:
2015-03-31 21:39:33
阅读次数:
84
今天下午做了一道题。leetcode merge intervals 属于比较难的题目。
首先用collections.sort 给list排序,然后用两个while loop来比较两个interval 的start, end 。 从而生成新的interal,再插入到新的list 返回结果。
下面给出自己的代码:
/*
50 Merge Intervals
https://leetcode.com/problems/merge-intervals/
Given a collection o...
分类:
其他好文 时间:
2015-03-31 14:47:07
阅读次数:
130
题意:给定一个字符串,查找最长的子串的长度(没有重复字符)。原题来自:https://leetcode.com/problems/longest-substring-without-repeating-characters/分析:我自己的思路,和曾经做的求最长公共子串长度一样,不过那个是用二维数组,...
分类:
其他好文 时间:
2015-03-31 12:22:39
阅读次数:
106
https://leetcode.com/problems/regular-expression-matching/Implement regular expression matching with support for'.'and'*'.'.' Matches any single chara...
分类:
其他好文 时间:
2015-03-30 22:52:12
阅读次数:
220