原创 LeetCode(E) Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1
原创 LeetCode(M) Sort List
Sort a linked list in O(n log n) time using constant space complexity. 根據題目O(nlogn)時間,O(1)空間,選擇了歸併排序 /** * Definit
原创 LintCode(M)兩數之和
兩數之和 描述 筆記 數據 評測 給一個整數數組,找到兩個數使得他們的和等於一個給定的數 target。 你需要實現的函數twoSum需要返回這兩個數的下標, 並且第一個下標小於第二個下標。注意這裏下標的範圍是 1
原创 LeetCode(M) Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the or
原创 LintCode(M)帶min函數的棧
帶最小值操作的棧 描述 筆記 數據 評測 實現一個帶有取最小值min方法的棧,min方法將返回當前棧中的最小值。 你實現的棧將支持push,pop 和 min 操作,所有操作要求都在O(1)時間內完成。 注意事項 如
原创 Linked List Cycle
Given a linked list, determine if it has a cycle in it. LintCode上原題 * Definition for singly-linked list. * struc
原创 Lintcode(S)落單的數
落單的數 描述 筆記 數據 評測 給出2*n + 1 個的數字,除其中一個數字之外其他每個數字均出現兩次,找到這個數字。 您在真實的面試中是否遇到過這個題? Yes 樣例 給出 [1,2,2,1,3,4,3],返
原创 Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL
原创 LintCode(M) 亂序字符串
亂序字符串 描述 筆記 數據 評測 給出一個字符串數組S,找到其中所有的亂序字符串(Anagram)。如果一個字符串是亂序字符串,那麼他存在一個字母集合相同,但順序不同的字符串也在S中。 注意事項 所有的字符串都只包
原创 大年三十,我又犯了哪些lua的錯誤
1. 2. for k,v in ipairs(a) do print(v) end k="y",v="c" -->此處報錯,k,v相當於全局變量,又在泛型for中,不能再賦值 點贊 收藏 分享
原创 Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or e
原创 Palindrome Linked List(迴文鏈表)
LintCode原題 Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time a
原创 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. class Solution {
原创 LintCode(M)三數之和
三數之和 描述 筆記 數據 評測 給出一個有n個整數的數組S,在S中找到三個整數a, b, c,找到所有使得a + b + c = 0的三元組。 注意事項 在三元組(a, b, c),要求a <= b <= c。 結
原创 LeetCode(M)threesum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets i