原创 LeetCode874. Walking Robot Simulation (模擬題)

A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible type

原创 LeetCode 891. Sum of Subsequence Widths (找規律)

Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the width of S be the

原创 LeetCode44. Wildcard Matching (DP,注意初始化)

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Ma

原创 LeetCode 877. Stone Game(簡單DP)

Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input

原创 LeetCode 124. Binary Tree Maximum Path Sum(樹中最長路徑和,遞歸)

Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of node

原创 LeetCode135. Candy (貪心)

There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these child

原创 LeetCode 715. Range Module / 57. Insert Interval(區間查詢更新,離散化)

A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfac

原创 LeetCode719. Find K-th Smallest Pair Distance (二分法,滑動窗口優化)

Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defin

原创 LeetCode 5. Longest Palindromic Substring (DP)

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. E

原创 LeetCode 95. Unique Binary Search Trees II (二叉搜索樹計數,卡特蘭數)

Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n. Example: In

原创 LeetCode 45. Jump Game II (貪心/bfs,dfs超時)

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element i

原创 LeetCode41. First Missing Positive (數組技巧)

Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Exa

原创 LeetCode 133. Clone Graph (dfs,複製圖)

Given the head of a graph, return a deep copy (clone) of the graph. Each node in the graph contains a label (int) and

原创 LeetCode 99. Recover Binary Search Tree (BST重建)

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. E

原创 LeetCode222. Count Complete Tree Nodes (完全二叉樹節點計數技巧)

Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia: I