Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a strin…
分类:LeetCode
Swift LeetCode 系列之 1: TwoSum
典型的hashMap 解决方法 class Solution { func twoSum(_ nums: [Int], _ target: Int) -> [Int] { var dic = [Int: Int](…
63. 不同路径 II
什么是好代码 好的代码是自解释的, 好的变量名, 好的结构. 后来复习解法 后来解法没有刚开始的时候解法简单. 尤其是使用 OBSTACLE_FLAG 替换掉magic number是一个好办法. class Solut…
Leetcode 76. Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in co…
53. Maximum Subarray
53. Maximum Subarray 题目 Find the contiguous subarray within an array (containing at least one number) which ha…
[LeetCode] Contains Duplicate III 包含重复值之三,Contains Duplicate II 包含重复值之二,Contains Duplicate II 包含重复值之二
Given an array of integers, find out whether there are two distinct indices i and j in the array such t…
[LeetCode] Best Time to Buy and Sell Stock with Transaction Fee 买股票的最佳时间含交易费
Your are given an array of integers prices, for which the i-th element is the price of a give…
LeetCode | Balanced Binary Tree
题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree i…
insertion-sort-list
思路 插入排序,维持两个链表,第一个原始链表,第二个排好序的链表。为了操作方便,第二个链表设置一个哑元dummy。当原始链表为空或者只有一个元素时,直接返回。如果不是,初始化dummy链表。每次从第一个链表中拿出一个元素…
[LeetCode By Go 39]404. Sum of Left Leaves
题目 Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left lea…
[LeetCode By Go 75]35. Search Insert Position
题目 Given a sorted array and a target value, return the index if the target is found. If not, return the index …
[LeetCode By Go 724] Easy, Array, 724. Find Pivot Index
题目 Given an array of integers nums, write a method that returns the “pivot” index of this array. W…