
leetcode
居南
这个作者很懒,什么都没留下…
展开
-
[LeetCode]476. Number Complement
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. 一个数求补数,用二进制表示,每位取反。 1.找到该数在32位时第一个非零位,开始取反。 class Solution原创 2017-05-10 18:03:54 · 170 阅读 · 0 评论 -
[LeetCode]237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value原创 2017-05-10 19:14:05 · 177 阅读 · 0 评论 -
[LeetCode]136. Single Number
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on原创 2017-05-10 22:27:33 · 177 阅读 · 0 评论 -
[LeetCode]202. Happy Number 快乐数
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares原创 2017-05-11 21:33:49 · 324 阅读 · 0 评论 -
[LeetCode]263. Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it i原创 2017-05-15 10:18:06 · 186 阅读 · 0 评论 -
[LeetCode]461. Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. 汉明距离:两个数原创 2017-05-09 20:19:58 · 234 阅读 · 0 评论 -
[LeetCode]371.Sum of Two Integers两数相加
371. Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. 两数相加,不使用加减符号。 使用异或、与、位移运算符。 class Solution { public: int getSum(int a, int b)原创 2017-05-09 12:58:14 · 205 阅读 · 0 评论