随笔分类 -  Leetcode

上一页 1 2 3 4 5 6 7 下一页

Leetcode: Reverse Nodes in k-Group
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文

posted @ 2014-11-17 12:26 Ryan-Xing 阅读(182) 评论(0) 推荐(0)

Rotate List
摘要:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.分析:此题... 阅读全文

posted @ 2014-11-16 15:59 Ryan-Xing 阅读(203) 评论(0) 推荐(0)

Sort List
摘要:Sort a linked list inO(nlogn) time using constant space complexity.分析:merge sort。class Solution {public: ListNode *sortList(ListNode *head) { ... 阅读全文

posted @ 2014-11-16 15:23 Ryan-Xing 阅读(201) 评论(0) 推荐(0)

Swap Nodes in Pairs
摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文

posted @ 2014-11-16 14:52 Ryan-Xing 阅读(117) 评论(0) 推荐(0)

Add Two Numbers
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文

posted @ 2014-11-16 14:17 Ryan-Xing 阅读(129) 评论(0) 推荐(0)

Remove Duplicates from Sorted List
摘要:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文

posted @ 2014-11-16 13:51 Ryan-Xing 阅读(127) 评论(0) 推荐(0)

Word Ladder II
摘要:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed... 阅读全文

posted @ 2014-10-29 17:45 Ryan-Xing 阅读(200) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array II
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.The a... 阅读全文

posted @ 2014-10-29 16:04 Ryan-Xing 阅读(144) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文

posted @ 2014-10-29 11:55 Ryan-Xing 阅读(131) 评论(0) 推荐(0)

Text Justification
摘要:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should p... 阅读全文

posted @ 2014-10-26 17:00 Ryan-Xing 阅读(145) 评论(0) 推荐(0)

Reverse Words in a String
摘要:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Cl... 阅读全文

posted @ 2014-10-25 21:05 Ryan-Xing 阅读(117) 评论(0) 推荐(0)

LRU Cache
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文

posted @ 2014-10-25 20:31 Ryan-Xing 阅读(176) 评论(0) 推荐(0)

Surrounded Regions
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region... 阅读全文

posted @ 2014-10-24 22:31 Ryan-Xing 阅读(162) 评论(0) 推荐(0)

Wildcard Matching
摘要:Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e... 阅读全文

posted @ 2014-10-22 22:38 Ryan-Xing 阅读(134) 评论(0) 推荐(0)

String to Integer (atoi)
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2014-10-22 16:03 Ryan-Xing 阅读(129) 评论(0) 推荐(0)

Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2014-10-22 14:01 Ryan-Xing 阅读(220) 评论(0) 推荐(0)

Decode Ways
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文

posted @ 2014-10-22 12:15 Ryan-Xing 阅读(133) 评论(0) 推荐(0)

Divide Two Integers
摘要:Divide two integers without using multiplication, division and mod operator.分析:不能用乘、除、取模运算,我们可以用的运算还有加、减、位运算。一个比较简单的想法是在dividend上不断减去divisor,知道余数小于div... 阅读全文

posted @ 2014-10-20 19:52 Ryan-Xing 阅读(136) 评论(0) 推荐(0)

3Sum
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文

posted @ 2014-10-19 19:39 Ryan-Xing 阅读(127) 评论(0) 推荐(0)

Median of Two Sorted Arrays
摘要:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文

posted @ 2014-10-19 16:57 Ryan-Xing 阅读(142) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 下一页