摘要: 题目描述: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 in... 阅读全文
posted @ 2015-12-28 15:32 scottwang 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For ... 阅读全文
posted @ 2015-12-28 14:52 scottwang 阅读(212) 评论(0) 推荐(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,... 阅读全文
posted @ 2015-12-28 14:40 scottwang 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目描述:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you ... 阅读全文
posted @ 2015-12-28 14:11 scottwang 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Reverse a singly linked list.解题思路:使用递归或者迭代的方法。代码如下:方法一:递归/** * Definition for singly-linked list. * public class ListNode { * int val; * ... 阅读全文
posted @ 2015-12-28 13:24 scottwang 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-b... 阅读全文
posted @ 2015-12-28 12:32 scottwang 阅读(306) 评论(0) 推荐(0) 编辑