167. Add Two Numbers【LintCode by java】】的更多相关文章

Description You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns…
Description Given a collection of intervals, merge all overlapping intervals. Example Given intervals => merged intervals: [ [ (1, 3), (1, 6), (2, 6), => (8, 10), (8, 10), (15, 18) (15, 18) ] ] Challenge O(n log n) time and O(1) extra space. 题意:给定一个…
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as…
Description Write a method to replace all spaces in a string with %20. The string is given in a characters array, you can assume it has enough space for replacement and you are given the true length of the string. You code should also return the new…
Description Given a non-overlapping interval list which is sorted by start point. Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary). Example Insert (2, 5) into [(1,2), (5,9)], we ge…
Description Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1. Example Given [1,2,4], return 1. 解题:至今仍然不理解这个“字典中的顺序”是什么意思,…
Description Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order. Example Given 1->3->8->11->15->null,…
Description Write a method anagram(s,t) to decide if two strings are anagrams or not. Clarification What is Anagram? Two strings are anagram if they can be the same after change the order of characters. Example Given s = "abcd", t = "dcab&q…
Description Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. There may exist multiple valid solutions, return any of them. Example Given [1,2,3,4,5,6,7], return 4 / \ 2 6 / \ / \ 1 3 5 7 解题:题目要求根据一个有序的数…
Description Sort a linked list using insertion sort. Example Given 1->3->2->0->null, return 0->1->2->3->null. 解题:用插入法排序链表.很简单的一道题目,但还是出现了很多问题. 总结一下遇到的问题: (1)没有头结点的情况下,为了方便可以构造一个,返回头结点的next就行了. (2)没有必要一直在原来的链表上纠结,完全可以申请一个头结点,将原链表结点一…