Merge 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.
题目意思为合并两个链表,不能用额外的空间(新链由两个链拼接而成)
思路:
比较简单,直接定义两个指针,分别...
分类:
其他好文 时间:
2014-12-25 22:09:16
阅读次数:
186
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->1-...
分类:
其他好文 时间:
2014-12-24 21:32:51
阅读次数:
214
题目:
Merge 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-linked list.
...
分类:
其他好文 时间:
2014-12-24 21:32:44
阅读次数:
236
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
Show Tags...
分类:
其他好文 时间:
2014-12-24 01:16:15
阅读次数:
148
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-12-23 23:49:51
阅读次数:
212
描述: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...
分类:
其他好文 时间:
2014-12-23 20:58:03
阅读次数:
158
Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run...
分类:
其他好文 时间:
2014-12-23 19:10:42
阅读次数:
174
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.SOLUTION 1:...
分类:
其他好文 时间:
2014-12-23 13:52:56
阅读次数:
200
Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ...
分类:
其他好文 时间:
2014-12-23 13:44:37
阅读次数:
108
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.
题目意思为删除链表中重复的元素
思路: ...
分类:
其他好文 时间:
2014-12-22 22:51:16
阅读次数:
191