自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 收藏
  • 关注

原创 Leetcode Combine Sum

给一个数组,一个target,求数组中所有和等于target的组合

2014-08-31 11:55:16 390

原创 Leetcode-Combine Sum II

Combination Sum II Total Accepted: 13634 Total Submissions: 55612My SubmissionsGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations in C wher

2014-08-31 11:26:54 338

原创 Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2014-07-13 14:10:33 314

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2014-07-13 00:20:08 307

原创 4Sum

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Element

2014-07-13 00:01:10 291

原创 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact

2014-07-12 23:52:12 246

原创 Two Sum && 3 Sum

Input: numbers={2, 7, 11, 15}, target=9Output: index1=1, index2=2pro:sol:

2014-07-12 23:34:06 283

原创 LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-07-12 22:41:52 244

原创 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2014-07-12 22:31:46 240

原创 Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is

2014-07-12 21:56:29 291

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2014-07-12 17:39:05 215

原创 Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

2014-07-12 17:21:19 286

原创 Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.pro:给一个liansol:code:

2014-07-12 16:37:35 296

原创 Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t

2014-07-12 16:02:22 240

原创 Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.pro:将两个sol:code:

2014-07-12 14:25:39 342

原创 Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-

2014-07-12 14:14:31 462

原创 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->3, return 1->2->3.pro:从排序lisol:code:

2014-07-12 13:42:45 269

原创 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2014-07-12 13:39:13 420

原创 Copy List with Random Pointer

pro:sol:code:

2014-07-12 12:37:53 293

原创 Linked List Cycle I&&II

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?procode:/** * Definition for singly-linked list. * struct ListNode {

2014-07-12 11:59:32 283

原创 Leetcode linked list

Insertion Sort Listpro:Sort a linked list using insertion sort.

2014-07-12 11:58:43 297

原创 Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically

2014-07-12 00:03:25 380

原创 Surrounded Regions

pro:给一个图,图包含'X'和‘O’,将图中所有的被包围的'O'置为‘X’,被包围的意思是周围都是'X',没有到边界。sol:有两个做法做法1:从每一个没被访问过的'O'开始,bfs或dfs,记录下这次有没有通过某个‘O’到达了边界,有的话就是不能置为'X'的,没有的话就能做法2:逆向思维,从矩阵的四边找,扩展所有能扩展的'O'.剩下的就是被包围的此题网页1A,awesome!

2014-07-11 23:55:12 256

原创 Word Ladder II

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exi

2014-07-11 23:49:56 529

原创 word ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word

2014-07-11 22:57:09 293

原创 Clone Graph

code:

2014-07-11 22:53:53 291

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除