随笔分类 -  ~~Leetcode~~

上一页 1 ··· 3 4 5 6 7
摘要:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2014-03-31 09:42 OpenSoucre 阅读(117) 评论(0) 推荐(0)
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2014-03-28 15:29 OpenSoucre 阅读(175) 评论(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 at... 阅读全文
posted @ 2014-03-28 14:31 OpenSoucre 阅读(131) 评论(0) 推荐(0)
摘要: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-03-28 14:15 OpenSoucre 阅读(154) 评论(0) 推荐(0)
摘要:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2014-03-27 23:48 OpenSoucre 阅读(120) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2014-03-27 18:36 OpenSoucre 阅读(121) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2014-03-27 18:10 OpenSoucre 阅读(186) 评论(0) 推荐(0)
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2014-03-27 17:20 OpenSoucre 阅读(156) 评论(0) 推荐(0)
摘要: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-03-27 15:44 OpenSoucre 阅读(233) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space.题意是判断整数是不是回文串,第一个想法是将整数转换为字符串,但题目要求不能用额外的空间第二个想法是将数字反过来,比较两个数字是不是相等,但将两个数字反过... 阅读全文
posted @ 2014-03-27 14:04 OpenSoucre 阅读(129) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500... 阅读全文
posted @ 2014-03-27 11:47 OpenSoucre 阅读(221) 评论(0) 推荐(0)
摘要:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
posted @ 2014-03-27 11:01 OpenSoucre 阅读(187) 评论(0) 推荐(0)
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321此题主要考查几种特殊的前导0的情况,还有单独为0的情况注意利用c++中的reverse时要加命名空间,不然该函数会递归调用自己... 阅读全文
posted @ 2014-03-26 18:16 OpenSoucre 阅读(200) 评论(0) 推荐(0)
摘要: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-03-26 17:29 OpenSoucre 阅读(185) 评论(0) 推荐(0)
摘要: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-03-24 21:15 OpenSoucre 阅读(211) 评论(0) 推荐(0)
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2014-03-24 00:37 OpenSoucre 阅读(197) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7