摘要: Problem: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, th 阅读全文
posted @ 2016-11-05 08:59 SillyVicky 阅读(115) 评论(0) 推荐(0)
摘要: Problem: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways c 阅读全文
posted @ 2016-11-05 07:49 SillyVicky 阅读(126) 评论(0) 推荐(0)
摘要: Problem: Given a sorted linked list, delete all duplicates such that each element appears only once. For example,Given 1->1->2, return 1->2.Given 1->1 阅读全文
posted @ 2016-11-04 23:56 SillyVicky 阅读(174) 评论(0) 推荐(0)
摘要: Problem: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positi 阅读全文
posted @ 2016-11-03 09:06 SillyVicky 阅读(914) 评论(0) 推荐(0)
摘要: Problem: Given an integer, write a function to determine if it is a power of three. Could you do it without using any loop / recursion? Summary: 用非循环/ 阅读全文
posted @ 2016-11-02 09:34 SillyVicky 阅读(163) 评论(0) 推荐(0)
摘要: Problem: Given an integer, write a function to determine if it is a power of two. Summary: 判断一个数n是不是2的整数幂。 Analysis: 这道题首先需要注意n为非整数是返回false的情况。 1. 若将n 阅读全文
posted @ 2016-11-01 12:04 SillyVicky 阅读(184) 评论(0) 推荐(0)
摘要: Problem: You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the tot 阅读全文
posted @ 2016-11-01 11:35 SillyVicky 阅读(615) 评论(0) 推荐(0)
摘要: Problem: Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Summary: 以字符串的形式求两个整形数相加。 Analysis: 这道题是 阅读全文
posted @ 2016-10-31 08:31 SillyVicky 阅读(273) 评论(0) 推荐(0)
摘要: Problem: Reverse a singly linked list. A linked list can be reversed either iteratively or recursively. Could you implement both? Summary: 翻转链表。 Analy 阅读全文
posted @ 2016-10-30 23:07 SillyVicky 阅读(192) 评论(0) 推荐(0)
摘要: Problem: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Summary: 将罗马数字转换为十进制阿拉伯数字。 Analys 阅读全文
posted @ 2016-10-30 12:14 SillyVicky 阅读(327) 评论(0) 推荐(0)