Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:
其他好文 时间:
2015-02-02 15:36:38
阅读次数:
182
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
解题思路:与之前刷过的一题有所不同,这里要求保...
分类:
其他好文 时间:
2015-02-02 14:15:43
阅读次数:
176
题目链接:Remove Duplicates from Sorted
Array
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 for ano...
分类:
其他好文 时间:
2015-02-02 12:34:17
阅读次数:
151
原题地址基本模拟题代码: 1 int removeDuplicates(int A[], int n) { 2 if (n <= 0) 3 return 0; 4 5 int i = 1; 6 int ...
分类:
其他好文 时间:
2015-02-02 12:06:25
阅读次数:
94
https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,...
分类:
其他好文 时间:
2015-02-02 00:37:13
阅读次数:
264
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->...
分类:
其他好文 时间:
2015-02-01 16:10:35
阅读次数:
187
本题的思路是二分查找,关键是怎么用二分查找。通过middle值和数组尾部的值比较,可以确定start-Middle和middle-end,这两部分那一部分是有序的,有序的数组是可以用二分查找的。class Solution {public: int search(int A[], int n,...
分类:
其他好文 时间:
2015-02-01 16:02:15
阅读次数:
193
https://oj.leetcode.com/problems/merge-two-sorted-lists/Merge two sorted linked lists and return it as a new list. The new list should be made by spli...
分类:
其他好文 时间:
2015-02-01 00:35:26
阅读次数:
147
https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/Given an array where elements are sorted in ascending order, convert it to...
分类:
其他好文 时间:
2015-01-31 23:08:44
阅读次数:
196
【题目】
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 ...
分类:
其他好文 时间:
2015-01-31 17:54:53
阅读次数:
203