代码改变世界

141_Linked List Cycle

2016-03-21 16:33 by FTD_W, 132 阅读, 0 推荐, 收藏, 编辑
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 判断一个单链表是否有环 解法一:记录下来遍历过的节点,但是当节点很多事会非常耗费 阅读全文

337_House Robber III

2016-03-20 17:11 by FTD_W, 135 阅读, 0 推荐, 收藏, 编辑
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文

35_Search Insert Position

2016-03-14 17:14 by FTD_W, 124 阅读, 0 推荐, 收藏, 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文

96_Unique Binary Search Trees

2016-03-14 11:23 by FTD_W, 130 阅读, 0 推荐, 收藏, 编辑
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文

137_Single Number II

2016-03-11 15:35 by FTD_W, 138 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear runtime c 阅读全文

328_Odd Even Linked List

2016-03-11 14:58 by FTD_W, 150 阅读, 0 推荐, 收藏, 编辑
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文

12_Integer to Roman

2016-03-08 16:13 by FTD_W, 129 阅读, 0 推荐, 收藏, 编辑
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 把整型数字转化为罗马数字。提前用一个字典表存储好所有对应关系即可 public cl 阅读全文

206_Reverse Linked List

2016-01-14 16:19 by FTD_W, 113 阅读, 0 推荐, 收藏, 编辑
摘要:Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct Li... 阅读全文

13_Roman to Integer

2016-01-13 15:05 by FTD_W, 176 阅读, 0 推荐, 收藏, 编辑
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字转化为阿拉伯数字I 1X 10C 100M 1000V 5L 50 ... 阅读全文

191_Number of 1 Bits

2016-01-13 14:38 by FTD_W, 125 阅读, 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 in... 阅读全文