- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 leetcode 第23题 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:自底向上递归实现,时间复杂度O(nlogk),空间复杂度O(k)c++代码实现:/** * Definition for singly-linked list. * struct ListNod
2015-04-26 11:18:30 420
原创 leetcode 第18题 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:Elements in a quadru
2015-04-26 09:54:26 305
原创 leetcode 第九题 Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the
2015-04-24 00:12:51 256
原创 leetcode 第8题 String to Integer(atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.N
2015-04-22 00:09:20 435
原创 leetcode 第136题 Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me
2015-04-16 20:05:43 324
原创 leetcode 第144题 Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3},1 \ 2 / 3return [1,2,3]. 思路:迭代方法实现,用一个stack + 一个vector实现java代码如下:/*
2015-04-16 00:33:44 369
原创 leetcode 第153题 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 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the array.思路:用b
2015-04-14 00:43:24 304
原创 leetcode 第27题 Remove Element
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 matter what you leave beyond the new length. 思路:额外定义一个
2015-04-13 07:46:34 433
原创 leetcode 第190题 Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110
2015-04-13 00:26:12 460
原创 leetcode 第160题 MinStack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the
2015-04-12 17:07:01 296
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人