摘要:
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Solution1: 不使用任何functiion 昨天 阅读全文
posted @ 2016-09-10 12:06
Machelsky
阅读(144)
评论(0)
推荐(0)
摘要:
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 思路:之前一直觉得罗马数字好麻烦,一刷的时候看到就头疼不想做。看了看wiki之后感觉 阅读全文
posted @ 2016-09-10 10:49
Machelsky
阅读(520)
评论(0)
推荐(0)
摘要:
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-09-10 09:27
Machelsky
阅读(114)
评论(0)
推荐(0)
摘要:
Reverse a singly linked list. Solution 1: 思路:null的使用。用一个null node来承接,一个一个接上去即可。一刷的时候还觉得这node转化好麻烦好神奇,熟悉之后其实做起来很快。 Solution 2: follow up : Use Recursio 阅读全文
posted @ 2016-09-10 08:32
Machelsky
阅读(100)
评论(0)
推荐(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 a 阅读全文
posted @ 2016-09-10 08:03
Machelsky
阅读(155)
评论(0)
推荐(0)
摘要:
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
posted @ 2016-09-10 07:37
Machelsky
阅读(124)
评论(0)
推荐(0)
摘要:
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2016-09-10 06:24
Machelsky
阅读(133)
评论(0)
推荐(0)
摘要:
思路:递归。 null也是tree。 null tree (definition) Definition: (1) A tree which is empty. (2) A tree whose leaf nodes all have a null value. https://xlinux.nis 阅读全文
posted @ 2016-09-10 05:09
Machelsky
阅读(126)
评论(0)
推荐(0)
摘要:
思路:纯递归。 阅读全文
posted @ 2016-09-10 04:57
Machelsky
阅读(99)
评论(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-bit i 阅读全文
posted @ 2016-09-10 03:42
Machelsky
阅读(192)
评论(0)
推荐(0)