原创 Java的Comparator和Comparable對比
1.對象如何對比排序? Java的基本類型如int, float, double都可以直接使用java.util.Arrays.sort(Object[])對比排序,那對象是如何比較排序的呢?我們定義的類都是繼承Object類的,Obje
原创 【LeetCode】Insert Interval
題目 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may
原创 【LeetCode】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
原创 【LeetCode】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->NUL
原创 【LeetCode】Remove Duplicates from Sorted List II
題目 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the o
原创 【LeetCode】Convert Sorted List to Binary Search Tree
題目 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 解答 題目要
原创 【LeetCode】Copy List with Random Pointer
題目 A linked list is given such that each node contains an additional random pointer which could point to any node in
原创 【LeetCode】Intersection of Two Linked Lists
題目 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the fo
原创 【LeetCode】Reorder List
題目 Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place w
原创 【LeetCode】Reverse Nodes in k-Group
題目 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number o
原创 【LeetCode】Remove Nth Node From End of List
題目 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked l
原创 【LeetCode】Swap Nodes in Pairs
題目 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should
原创 【LeetCode】Two Sum
題目 Given an array of integers, find two numbers such that they add up to a specific target number. The function twoS
原创 面向GC的Java編程-coolshell
Java程序員在編碼過程中通常不需要考慮內存問題,JVM經過高度優化的GC機制大部分情況下都能夠很好地處理堆(Heap)的清理問題。以至於許多Java程序員認爲,我只需要關心何時創建對象,而回收對象,就交給GC來做吧!甚至有人說,如果在
原创 【LeetCode】Linked List Cycle II
題目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can yo