- 博客(9)
- 收藏
- 关注
原创 NO.9_476. Number Complement
476. Number Complement Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guara
2017-01-15 22:00:06 543
原创 NO.8_485. Max Consecutive Ones
485. Max Consecutive Ones Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the
2017-01-15 20:22:14 167
原创 NO.7_136. Single Number
136. Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you impl
2017-01-14 22:00:29 224
原创 NO.6_292. Nim Game
292. Nim Game You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the las
2017-01-14 20:59:12 229
原创 NO.5_448. Find All Numbers Disappeared in an Array
448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of
2017-01-14 20:43:16 161
原创 NO.4_463. Island Perimeter
463. Island Perimeter //参考解 //总数减错误计算的 int islandPerimeter(vector>& grid) { int count=0, repeat=0; for(int i=0;i<grid.size();i++) { for(int j=0; j<grid[i].size
2017-01-11 16:41:59 170
原创 NO.3_344. Reverse String
344. Reverse String 解法1(不好): class Solution { public: string reverseString(string s) { string a; const char *t = s.c_str();//string转char* int length=s.length();
2017-01-10 21:33:14 152
原创 NO.2_412. Fizz Buzz
412. Fizz Buzz //解1 class Solution { public: vector fizzBuzz(int n) { vector a; std::stringstream ss; std::string str_out; for(int i=1; i<=n; ++i) {
2017-01-10 20:29:44 222
原创 NO.1_461. Hamming Distance
class Solution { public: int hammingDistance(int x, int y) { int p=x^y; int a=0; while(p)//找出所有的1 { a=a+(p&1); p=p>>1;
2017-01-09 10:41:39 340
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人