Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... Read More
posted @ 2015-08-04 16:28 sunalive Views(110) Comments(0) Diggs(0)
1 class Solution { 2 public: 3 int calculate(int n) 4 { 5 int res = 0; 6 while(n > 0) 7 { 8 int tmp = n%1... Read More
posted @ 2015-08-04 15:57 sunalive Views(122) Comments(0) Diggs(0)
Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... Read More
posted @ 2015-08-04 14:35 sunalive Views(164) Comments(0) Diggs(0)
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].思想很简单逐个比较... Read More
posted @ 2015-08-04 11:18 sunalive Views(121) Comments(0) Diggs(0)
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at... Read More
posted @ 2015-08-02 19:59 sunalive Views(129) Comments(0) Diggs(0)
判断一颗二叉树是否为对称的,思路如下: 1)判断递归左右子树是否相等,通过比较左子树的左孩子和有右子树的右孩子,左子树的右孩子和右子树的左孩子。class Solution {public: bool isJudge(TreeNode* left, TreeNode* right){ ... Read More
posted @ 2015-07-31 21:18 sunalive Views(148) Comments(0) Diggs(0)
// Heap.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#includeint h[101];//存放数组int n;//存放数组元素个数using namespace std;//void swap(int *a,int *b)//{// int temp... Read More
posted @ 2015-07-09 10:36 sunalive Views(139) Comments(0) Diggs(0)
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... Read More
posted @ 2015-06-18 09:25 sunalive Views(151) Comments(0) Diggs(0)
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... Read More
posted @ 2015-06-15 14:10 sunalive Views(137) Comments(0) Diggs(0)
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... Read More
posted @ 2015-06-10 20:24 sunalive Views(121) Comments(0) Diggs(0)