2016年3月11日

22. Generate Parentheses

摘要: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: " 阅读全文

posted @ 2016-03-11 11:12 olive_lv 阅读(144) 评论(0) 推荐(0)

2016年3月9日

35. Search Insert Position

摘要: 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 阅读全文

posted @ 2016-03-09 09:21 olive_lv 阅读(97) 评论(0) 推荐(0)

83. Remove Duplicates from Sorted List

摘要: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3-> 阅读全文

posted @ 2016-03-09 09:21 olive_lv 阅读(141) 评论(0) 推荐(0)

137. Single Number II

摘要: Given an array of integers, every element appears three times except for one. Find that single one. 结题报告: 方法一: 使用map记录每个数字出现的次数,找到出现次数不为3的数。 class Sol 阅读全文

posted @ 2016-03-09 09:20 olive_lv 阅读(114) 评论(0) 推荐(0)

116. Populating Next Right Pointers in Each Node

摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文

posted @ 2016-03-09 09:20 olive_lv 阅读(152) 评论(0) 推荐(0)

191. Number of 1 Bits

摘要: 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, the 32-bit 阅读全文

posted @ 2016-03-09 09:19 olive_lv 阅读(150) 评论(0) 推荐(0)

235. Lowest Common Ancestor of a Binary Search Tree

摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文

posted @ 2016-03-09 09:19 olive_lv 阅读(107) 评论(0) 推荐(0)

141. Linked List Cycle

摘要: Given a linked list, determine if it has a cycle in it. 解题思路: #include<windows.h> #include<iostream> using namespace std; struct ListNode { int val; L 阅读全文

posted @ 2016-03-09 09:19 olive_lv 阅读(109) 评论(0) 推荐(0)

108. Convert Sorted Array to Binary Search Tree

摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 解题思路: 分开考虑n==0 n==1 n==2的情况,可将原来20ms时间提升至16ms #inclu 阅读全文

posted @ 2016-03-09 09:19 olive_lv 阅读(98) 评论(0) 推荐(0)

13. Roman to Integer

摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解题思路: 屏幕剪辑的捕获时间: 2016/3/4 22:52 从左到右,两两进行比 阅读全文

posted @ 2016-03-09 09:17 olive_lv 阅读(106) 评论(0) 推荐(0)

导航