摘要:
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. 阅读全文
posted @ 2016-09-11 15:18
Machelsky
阅读(129)
评论(0)
推荐(0)
摘要:
Given 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 阅读全文
posted @ 2016-09-11 14:25
Machelsky
阅读(102)
评论(0)
推荐(0)
摘要:
Sort a linked list in O(n log n) time using constant space complexity. 虽然知道要用mergesort,也懂mergesort,但没有自己实现过。真正上手的时候就不回=。=。参考了discussion的思路。 思路:找到linke 阅读全文
posted @ 2016-09-11 07:55
Machelsky
阅读(142)
评论(0)
推荐(0)
摘要:
121. Best Time to Buy and Sell Stock 121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stoc 阅读全文
posted @ 2016-09-11 06:45
Machelsky
阅读(128)
评论(0)
推荐(0)
摘要:
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 - 阅读全文
posted @ 2016-09-11 05:51
Machelsky
阅读(103)
评论(0)
推荐(0)
摘要:
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 阅读全文
posted @ 2016-09-11 05:34
Machelsky
阅读(149)
评论(0)
推荐(0)
摘要:
Invert a binary tree. to 阅读全文
posted @ 2016-09-11 05:14
Machelsky
阅读(123)
评论(0)
推荐(0)
摘要:
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2016-09-11 04:02
Machelsky
阅读(164)
评论(0)
推荐(0)
摘要:
Given 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, giv 阅读全文
posted @ 2016-09-11 03:18
Machelsky
阅读(159)
评论(0)
推荐(0)
摘要:
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Solution1: 这道题做的太麻烦了,corner case很多,碰到负数不知道怎么给reverse。强行转成st 阅读全文
posted @ 2016-09-11 03:00
Machelsky
阅读(154)
评论(0)
推荐(0)