- 博客(17)
- 收藏
- 关注
原创 278. First Bad Version
First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is develo
2016-04-27 22:53:30 222
原创 344. Reverse String
Reverse StringWrite a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.public class Solution { public String reverseString(String s)
2016-04-25 22:48:56 223
原创 345. Reverse Vowels of a String
Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string.Example 1: Given s = “hello”, return “holle”.Example 2: Given s = “leetcode”, return “l
2016-04-24 22:38:31 315
原创 189. Rotate Array
Rotate Array Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as
2016-04-23 20:11:21 199
原创 219. Contains Duplicate II
Contains Duplicate IIGiven an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is
2016-04-22 17:21:24 202
原创 217. Contains Duplicate
Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if
2016-04-22 15:41:57 207
原创 283. Move Zeroes
Move ZeroesGiven an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling
2016-04-21 22:24:32 199
原创 66. Plus One
Plus OneGiven 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 the head of the list.把一个数字放在数组里,然后让这个数字加一。
2016-04-20 22:10:39 238
原创 27. Remove Element
Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant me
2016-04-20 20:10:58 226
原创 26. Remove Duplicates from Sorted Array
Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array,
2016-04-20 19:40:28 198
原创 21. Merge Two Sorted Lists
Merge Two Sorted ListsMerge 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.合并两个有序链表/** * Definition for singly-l
2016-04-18 22:35:03 196
原创 148. Sort List
Sort ListSort a linked list in O(n log n) time using constant space complexity.对一个链表排序,要求O(n log n)的时间复杂度。 因为Java提供了O(n log n)复杂度排序的算法,所以就不自己写了。。。
2016-04-18 19:50:14 230
原创 141. Linked List Cycle
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?给一个链表,判断链表里是否有环,并且不使用额外的空间。 很简单,定义两个指针,slow和fast,fast每次步进2,slow每次步进1,如果fa
2016-04-18 18:57:11 248
原创 80. Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array II
2016-04-13 17:56:11 252
原创 19. 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 linke
2016-04-13 16:56:49 219
原创 24. 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 spa
2016-04-11 22:58:43 258
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人