摘要: 题目描述 输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。 public class Solution { public int NumberOf1(int n) { int count = 0; while(n!= 0){ count++; n = n & (n - 1); } r 阅读全文
posted @ 2016-09-15 15:04 萝卜er 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the neare 阅读全文
posted @ 2016-09-15 12:40 萝卜er 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目描述 有两个用链表表示的整数,每个结点包含一个数位。这些数位是反向存放的,也就是个位排在链表的首部。编写函数对这两个整数求和,并用链表形式返回结果。 给定两个链表ListNode* A,ListNode* B,请返回A+B的结果(ListNode*)。 测试样例: {1,2,3},{3,2,1} 阅读全文
posted @ 2016-09-15 02:23 萝卜er 阅读(234) 评论(0) 推荐(0) 编辑