原创 LeetCode(169)——Majority Element
題目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n
原创 ThreadLocal
1、ThreadLocal是什麼? 顧名思義,線程級的本地變量,也就是線程之間是隔離的,不共享。適合不同線程存儲各自的上下文。webapp中應用較多。 2、ThreadLocal中的屬性和方法 private final int
原创 LeetCode(125)——Valid Palindrome
題目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note:
原创 LeetCode(108)——Convert Sorted Array to Binary Search Tree
題目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem,
原创 【Java基礎】四種引用(強引用、軟引用、弱引用、虛引用)
java中的引用類似C/C++中的指針,都是指向內存中的某個對象,通過該引用可以直接操作對應的對象。引用和GC有着直接關係,根據可達性分析算法(從一個被稱爲 GC Roots 的對象開始向下搜索,如果一個對象到GC Roots沒有任何引用
原创 LeetCode(111)——Minimum Depth of Binary Tree
題目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from
原创 LeetCode(114)——Flatten Binary Tree to Linked List
題目: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2
原创 LeetCode(5)——Longest Palindromic Substring
題目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
原创 LeetCode(103)——Binary Tree Zigzag Level Order Traversal
題目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then ri
原创 LeetCode(112)——Path Sum
題目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values alo
原创 LeetCode(14)——Longest Common Prefix
題目: Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix
原创 LeetCode(113)——Path Sum II
題目: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf
原创 LeetCode(94)——Binary Tree Inorder Traversal
題目: Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \
原创 LeetCode(121)——Best Time to Buy and Sell Stock
題目: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted
原创 LeetCode(217)——Contains Duplicate
題目: Given an array of integers, find if the array contains any duplicates. Your function should return true if any valu