摘要:
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: Solution2: 把数字减一再运算就不用考虑其他问题了。参考了discussion
阅读全文
posted @ 2016-09-13 07:08
Machelsky
阅读(156)
推荐(0)
摘要:
Given 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 fo
阅读全文
posted @ 2016-09-12 06:41
Machelsky
阅读(124)
推荐(0)
摘要:
Write a function to find the longest common prefix string amongst an array of strings. Solution1: 思路:没有想到什么巧妙方法。就用recursion暴力硬做。发现只要想法对,recursion怎么做都能
阅读全文
posted @ 2016-09-12 06:31
Machelsky
阅读(165)
推荐(0)
摘要:
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in
阅读全文
posted @ 2016-09-12 05:20
Machelsky
阅读(131)
推荐(0)
摘要:
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? Solution1: 思路:有cycle:1.循环退不出来2.有个节点被指两次。
阅读全文
posted @ 2016-09-12 04:35
Machelsky
阅读(112)
推荐(0)
摘要:
Determine whether an integer is a palindrome. Do this without extra space. Solution1: 思路:按题目的意思就是负数不能是palindrome。用reverse integer函数判断即可。
阅读全文
posted @ 2016-09-12 03:44
Machelsky
阅读(109)
推荐(0)
摘要:
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)
摘要:
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)
摘要:
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)
摘要:
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)