Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt...
分类:
其他好文 时间:
2014-07-22 22:48:14
阅读次数:
224
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or...
分类:
编程语言 时间:
2014-07-22 00:39:35
阅读次数:
263
My first reaction: move all A elements back by n positions, and start everything from A[0] and B[0]. But a smarter idea is to start everything from th...
分类:
其他好文 时间:
2014-07-22 00:35:36
阅读次数:
189
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to...
分类:
其他好文 时间:
2014-07-22 00:35:34
阅读次数:
238
冒泡排序代码:
#include
#include
using namespace std;
template
void bubbleSort(ItemType theArray[], int n)
{
bool sorted = false; // False when swaps occur
int pass = 1;
while (!sorted && (pass...
分类:
其他好文 时间:
2014-07-22 00:32:35
阅读次数:
363
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:
其他好文 时间:
2014-07-22 00:13:35
阅读次数:
154
1.Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
2.Given a singly linked list where elements are sorted in ascending order, convert it to a heig...
分类:
其他好文 时间:
2014-07-21 23:45:53
阅读次数:
264
题目: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).You are given a target ....
分类:
编程语言 时间:
2014-07-21 14:37:05
阅读次数:
266
题目:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the....
分类:
编程语言 时间:
2014-07-21 11:14:07
阅读次数:
203
Simply care about the boundary cases:class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { if (l1 && !l2) return l1;...
分类:
其他好文 时间:
2014-07-21 11:07:04
阅读次数:
206