Skip to content

hartl3y94/leetcode-php

 
 

💫 LeetCode for PHP 🐘

Build Status Build status PHP Composer codecov StyleCI Quality Gate Status Scrutinizer Code Quality FOSSA Status Version

Requirements

  • PHP >= 8.0
  • PHPUnit >= 9.5

Installation

Install the package through Composer.

Run the Composer require command from the Terminal:

git clone [email protected]:imajinyun/leetcode-php.git
cd leetcode-php
composer install

Usage

phpunit -vvv

Contents

LeetCode

String
题目 来源 实现
Array
题目 来源 实现
0001. 两数之和 Two Sum Solution
0118. 杨辉三角 Pascal's Triangle Solution
0026. 删除有序数组中的重复项 Remove Duplicates from Sorted Array Solution
0027. 移除元素 Remove Element
0035. 搜索插入位置 Search Insert Position
0053. 最大子序和 Maximum Subarray
0066. 加一 Plus One
0088. 合并两个有序数组 Merge Sorted Array
0118. 杨辉三角 Pascal's Triangle
0119. 杨辉三角 II Pascal's Triangle II
0121. 买卖股票的最佳时机 Best Time to Buy and Sell Stock
0122. 买卖股票的最佳时机 II Best Time to Buy and Sell Stock II
0163. 缺失的区间 Missing Ranges Solution
0167. 两数之和 II - 输入有序数组 Two Sum II - Input array is sorted
0169. 多数元素 Majority Element
0217. 存在重复元素 Contains Duplicate
0219. 存在重复元素 II Contains Duplicate II
0228. 汇总区间 Summary Ranges
0243. 最短单词距离 Shortest Word Distance
0268. 丢失的数字 Missing Number
0283. 移动零 Move Zeroes
0414. 第三大的数 Third Maximum Number
0448. 找到所有数组中消失的数字 Find All Numbers Disappeared in an Array
0485. 最大连续 1 的个数 Max Consecutive Ones
0509. 斐波那契数 Fibonacci Number
0561. 数组拆分 I Array Partition I
0566. 重塑矩阵 Reshape the Matrix
0605. 种花问题 Can Place Flowers
0628. 三个数的最大乘积 Maximum Product of Three Numbers
0643. 子数组最大平均数 I Maximum Average Subarray I
0661. 图片平滑器 Image Smoother Solution
0674. 最长连续递增序列 Longest Continuous Increasing Subsequence Solution
0697. 数组的度 Degree of an Array Solution
0717. 1 比特与 2 比特字符 1-bit and 2-bit Characters Solution
0724. 寻找数组的中心下标 Find Pivot Index Solution
0746. 使用最小花费爬楼梯 Min Cost Climbing Stairs Solution
0747. 至少是其他数字两倍的最大数 Largest Number At Least Twice of Others Solution
0766. 托普利茨矩阵 Toeplitz Matrix Solution
0830. 较大分组的位置 Positions of Large Groups Solution
0832. 翻转图像 Flipping an Image Solution
0867. 转置矩阵 Transpose Matrix Solution
0888. 公平的糖果棒交换 Fair Candy Swap Solution
0896. 单调数列 Monotonic Array Solution
0905. 按奇偶排序数组 Sort Array By Parity Solution
0914. 卡牌分组 X of a Kind in a Deck of Cards Solution
0922. 按奇偶排序数组 II Sort Array By Parity II Solution
0941. 有效的山脉数组 Valid Mountain Array Solution
0977. 有序数组的平方 Squares of a Sorted Array Solution
0985. 查询后的偶数和 Sum of Even Numbers After Queries Solution
0989. 数组形式的整数加法 Add to Array-Form of Integer Solution
0999. 可以被一步捕获的棋子数 Available Captures for Rook Solution
1002. 查找常用字符 Find Common Characters Solution
1013. 将数组分成和相等的三个部分 Partition Array Into Three Parts With Equal Sum Solution
1018. 可被 5 整除的二进制前缀 Binary Prefix Divisible By 5 Solution
1051. 高度检查器 Height Checker Solution
1064. 不动点 Fixed Point Solution
1085. 最小元素各数位之和 Sum of Digits in the Minimum Number Solution
1086. 前五科的均分 High Five Solution
1089. 复写零 Duplicate Zeros Solution
1099 小于 K 的两数之和 Two Sum Less Than K Solution
1122. 数组的相对排序 Relative Sort Array Solution
1128. 等价多米诺骨牌对的数量 Number of Equivalent Domino Pairs Solution
Linked List
题目 来源 实现
0002. 两数相加 Add Two Numbers Solution
0024. 两两交换链表中的节点 Swap Nodes in Pairs Solution
0206. 反转链表 Reverse Linked List Solution
0141. 环形链表 Linked List Cycle Solution
Stack
题目 来源 实现
0020. 有效的括号 Valid Parentheses Solution
0496. 下一个更大元素 I Next Greater Element I
0503. 下一个更大元素 II Next Greater Element II
0739. 每日温度 Daily Temperatures
Queue
题目 来源 实现
0239. 滑动窗口最大值 Sliding Window Maximum
Heap
题目 来源 实现
0703. 数据流中的第 K 大元素 Kth Largest Element in a Stream
Tree
题目 来源 实现
0020. 括号生成 Generate Parentheses
0098. 验证二叉搜索树 Validate Binary Search Tree
0100. 相同的树 Same Tree
0102. 二叉树的层序遍历 Binary Tree Level Order Traversal
0103. 二叉树的锯齿形层次遍历 Binary Tree Zigzag Level Order Traversal
0104. 二叉树的最大深度 Maximum Depth of Binary Tree
0199. 二叉树的右视图 Binary Tree Right Side View
0235. 二叉搜索树的最近公共祖先 Lowest Common Ancestor of a Binary Search Tree
0236. 二叉树的最近公共祖先 Lowest Common Ancestor of a Binary Tree
0450. 删除二叉搜索树中的节点 Delete Node in a Binary Search Tree
0515. 在每个树行中找最大值 Find Largest Value in Each Tree Row
0637. 二叉树的层平均值 Average of Levels in Binary Tree
0700. 二叉搜索树中的搜索 Search in a Binary Search Tree
0701. 二叉搜索树中的插入操作 Insert into a Binary Search Tree
0993. 二叉树的堂兄弟节点 Cousins in Binary Tree
Graph
题目 来源 实现
Math
题目 来源 实现
0050. 计算 x 的 n 次幂 Pow(x, n)
Union Find
题目 来源 实现
0200. 岛屿数量 Number of Islands
Graph
题目 来源 实现
Binary Search
题目 来源 实现
0069. x 的平方根 Sqrt(x)
Dynamic Programming
题目 来源 实现
0005. 最长回文子串 Longest Palindromic Substring
0062. 不同路径 Unique Paths
0063. 不同路径 II Unique Paths II
0064. 最小路径和 Minimum Path Sum
0070. 爬楼梯 Climbing Stairs
0072. 编辑距离 Edit Distance
0120. 三角形最小路径和 Triangle
0121. 买卖股票的最佳时机 Best Time to Buy and Sell Stock
0122. 买卖股票的最佳时机 II Best Time to Buy and Sell Stock II
0123. 买卖股票的最佳时机 III Best Time to Buy and Sell Stock III
0128. 最长连续序列 Longest Consecutive Sequence
0152. 乘积最大子数组 Maximum Product Subarray
0188. 买卖股票的最佳时机 IV Best Time to Buy and Sell Stock IV
0300. 最长上升子序列 Longest Increasing Subsequence
0322. 零钱兑换 Coin Change
0309. 佳买卖股票时机含冷冻期 Best Time to Buy and Sell Stock with Cooldown
0673. 最长递增子序列的个数 Number of Longest Increasing Subsequence
0674. 最长连续递增序列 Longest Continuous Increasing Subsequence
0714. 买卖股票的最佳时机含手续费 Best Time to Buy and Sell Stock with Transaction Fee
1143. 最长公共子序列 Longest Common Subsequence
1397. 找到所有好字符串 Find All Good Strings
Recursion
题目 来源 实现
0509. 斐波那契数 Fibonacci Number
Divide and Conquer
题目 来源 实现
0169. 多数元素 Majority Element
Backtracking
题目 来源 实现
0036. 有效的数独 Valid Sudoku
0037. 解数独 Sudoku Solver
0039. 组合总和 Combination Sum
0040. 组合总和 II Combination Sum II
0046. 全排列 Permutations
0047. 全排列 II Permutations II
0051. N 皇后 N-Queens
0052. N 皇后 II N-Queens II
0078. 子集 Subsets
0079. 单词搜索 Word Search
0090. 子集 II Subsets II
Design
题目 来源 实现
0208. 实现 Trie(前缀树) Implement Trie (Prefix Tree)
0225. 用队列实现栈 Implement Stack using Queues
0232. 用栈实现队列 Implement Queue using Stacks
Two Pointers
题目 来源 实现
0015. 三数之和 3Sum
0016. 最接近的三数之和 3Sum Closest
0018. 四数之和 4Sum
Sliding Window
题目 来源 实现
0003. 无重复字符的最长子串 Longest Substring Without Repeating Characters
0076. 最小覆盖子串 Minimum Window Substring
0438. 找到字符串中所有字母异位词 Find All Anagrams in a String
0567. 字符串的排列 Permutation in String
Bit Manipulation
题目 来源 实现
0191. 位 1 的个数 Number of 1 Bits
0231. 2 的幂 Power of Two
0338. 比特位计数 Counting Bits
Unclassified
题目 来源 实现
0242. 有效的字母异位词 Valid Anagram
1118. 一月有多少天 Number of Days in a Month

剑指 Offer

程序员面试金典

License

FOSSA Status

About

💫 LeetCode for PHP 🐘

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%