1,从System.String[]转到ListSystem.String[] 
str={"str","string","abc"};List listS=new List(str);2, 
从List转到System.String[]List listS=new List();listS.Add("...
                            
                            
                                分类:
其他好文   时间:
2014-06-12 19:24:08   
                                阅读次数:
206
                             
                    
                        
                            
                            
                                Question:Sort a linked list inO(nlogn) time 
using constant space complexity.Solution:Merge sort.找到链表的中间的那个ListNode. 1 /** 2 
* Definition for singly-l....
                            
                            
                                分类:
其他好文   时间:
2014-06-12 17:59:34   
                                阅读次数:
285
                             
                    
                        
                            
                            
                                题目
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-06-11 00:41:44   
                                阅读次数:
207
                             
                    
                        
                            
                            
                                Given two sorted integer arrays A and B, merge 
B into A as one sorted array.Note:You may assume that A has enough space (size 
that is greater or equal...
                            
                            
                                分类:
其他好文   时间:
2014-06-10 20:44:02   
                                阅读次数:
298
                             
                    
                        
                            
                            
                                Question: Mergeksorted linked lists and return 
it as one sorted list. Analyze and describe its complexity.Solution: Find the 
smallest list-head first....
                            
                            
                                分类:
其他好文   时间:
2014-06-10 19:51:30   
                                阅读次数:
278
                             
                    
                        
                            
                            
                                移除数组中重复次数超过2次以上出现的数,但是可以允许重复2次。
这个题类似Remove Duplicates from Sorted Array,第一个想法很直接就是计数,超过2次的就忽略,依据这个思路的代码见代码一;
上面的思路可行,但是代码看着比较冗余,判断比较多。再来想想原来的数组,该数组是排好序的,如果一个数出现3次以上,那么必有A[i] == A[i-2]。所以根据这个关系可以写出比较精简的代码二。详见代码。...
                            
                            
                                分类:
其他好文   时间:
2014-06-10 19:18:39   
                                阅读次数:
250
                             
                    
                        
                            
                            
                                题目
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.
方法
有序链表,合并成一个有序链表。
	   public ListNod...
                            
                            
                                分类:
其他好文   时间:
2014-06-10 18:13:11   
                                阅读次数:
241
                             
                    
                        
                            
                            
                                int removeDuplicates(int A[], int n) {
        if(n <= 1)
        return n;
        int newIndex = 0;
        for(int i = 1; i < n; ++i){
            if(A[i] != A[newIndex])
            A[++newIndex] ...
                            
                            
                                分类:
其他好文   时间:
2014-06-10 10:57:49   
                                阅读次数:
131
                             
                    
                        
                            
                            
                                问题:
给定一个有序链表,生成对应的平衡二叉搜索树。
分析
见Convert
 Sorted Array to Binary Search Tree
实现:
TreeNode *buildTree(ListNode* head, ListNode *end){
        if(head == NULL || head == end)
        return NULL;
  ...
                            
                            
                                分类:
其他好文   时间:
2014-06-10 07:17:29   
                                阅读次数:
264