原创 LeetCode_圓圈中最後剩下的數字_Math_E

面試題62. 圓圈中最後剩下的數字 class Solution { public int lastRemaining(int n, int m) { // 模擬法 List<Integer> l

原创 LeetCode_單詞的壓縮編碼_Array_M

820. 單詞的壓縮編碼   暴力.. class Solution { public int minimumLengthEncoding(String[] words) { String[] temp = ne

原创 LeetCode_地圖分析_BFS_M

1162. 地圖分析 class Solution { public int maxDistance(int[][] grid) { Queue<Node> queue = new LinkedList<>();

原创 LeetCode_卡牌分組_Array_E

914. 卡牌分組 // 暴力.. class Solution { public boolean hasGroupsSizeX(int[] deck) { int[] temp = new int[10000]

原创 LeetCode_兩數之和_Array_E

1. 兩數之和    暴力: class Solution { public int[] twoSum(int[] nums, int target) { int[] res = new int[2];

原创 LeetCode_字符串轉換整數 (atoi)_String_M

8. 字符串轉換整數 (atoi) class Solution { public int myAtoi(String str) { if (str == null || str.length() == 0 ||

原创 LeetCode_旋轉矩陣_Array_M

01.07. 旋轉矩陣 簡單粗暴: class Solution { public void rotate(int[][] matrix) { int size = matrix.length;

原创 LeetCode_盛最多水的容器_Array_M

11. 盛最多水的容器     暴力...  class Solution { public int maxArea(int[] height) { int max = 0; for (int i

原创 Trie 前綴樹/字典樹

一、Trie的介紹:     1、主要應用場景:搜索引擎的自動補全功能:Trie樹+詞頻(概率)權重因子                                    IP路由:最長前綴匹配,Trie路由算法          

原创 LeetCode_除自身以外數組的乘積_Array_M

238. 除自身以外數組的乘積   不能用除法,不能額外空間,所以先用一個數組存第 i 位左邊的所有數乘積,再倒過來遍歷賦值:res = 左邊乘積 * 右邊乘積 class Solution { public int[] pro

原创 LeetCode_整數反轉_Math_E

7. 整數反轉 class Solution { public int reverse(int x) { long result = 0; while (x != 0) { // 如果是-1

原创 Spring Bean的生命週期、BeanFactory和FactoryBean的區別

一、Spring Bean的生命週期   二、Spring BeanFactory和FactoryBean的區別

原创 LeetCode_有效的括號_Stack_E

20. 有效的括號 class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>();

原创 LeetCode_實現 Trie (前綴樹)_Trie_M

208. 實現 Trie (前綴樹) class Trie { //定義節點 class TrieNode { boolean isEnd; TrieNode[] next = new

原创 LeetCode_排序數組_Array_M

912. 排序數組 class Solution { public int[] sortArray(int[] nums) { quickSort(nums, 0, nums.length - 1);