leetcode-js
Leecode 经典题目 JavaScript TypeScript 题解。 Leetcode's answers by JavaScript and TypeScript.
easy
- 1.两数之和 (Two Sum)
- 7.整数反转 (Reverse Integer)
- 9.回文数 (Palindrome Number)
- 13.罗马数字转整数 (Roman to Integer)
- 14.最长公共前缀 (Longest Common Prefix)
- 20.有效的括号 (Valid Parentheses)
- 21.合并两个有序链表 (Merge Two Sorted Lists)
- 26.删除排序数组中的重复项 (Remove Duplicates from Sroted Array)
- 27.移除元素 (Remove Element)
- 28.实现 strStr() (Implement strStr())
- 35.搜索插入位置 (Search Insert Position)
- 38.外观数列 (Count and Say)
- 53.最大子序和 (Maximum Subarray)
- 58.最后一个单词的长度 (Length of Last World)
- 66.加一 (Plus One)
- 67.二进制求和 (Add Binary)
- 69.x 的平方根 (Sqrt(x))
- 70.爬楼梯 (Climbing Stairs)
- 83.删除排序链表中的重复元素 (Remove Duplicates from Sorted List)
- 88.合并两个有序数组 (Merge Sorted Array)
- 100.相同的树 (Same Tree)
- 104.二叉树的最大深度 (Maximum Depth of Binary Tree)
- 118.杨辉三角 (Pascal's Triangle)
- 119.杨辉三角 II (Pascal's Triangle)
- 121.买卖股票的最佳时机 (Best Time to Buy and Sell Stock)
- 125.验证回文串 (Valid Palindrome)
- 136.只出现一次的数字 (Single Number)
- 141.环形链表 (Linked List Cycle)
- 155.最小栈 (Min Stack)
- 167.两数之和 II - 输入有序数组 (Two Sum II - Input array is sorted)
- 168.Excel 表列名称 (Excel Sheet Column Title)
- 169.多数元素 (Majority Element)
- 171.Excel 表列序号 (Excel Sheet Column Number)
- 172.阶乘后的零 (Factorial Trailing Zeroes)
- 183.从不订购的客户 (Customers Who Never Order)
- 189.旋转数组 (Rotate Array)
- 190.颠倒二进制位 (Reverse Bits)
- 191.位 1 的个数 (Number of 1 Bits)
- 195.第十行 (Tenth Line)
- 196.删除重复的电子邮箱 (Delete Duplicate Emails)
- 202.快乐数 (Happy Number)
- 203.移除链表元素 (Remove Linked List Elements)
- 205.同构字符串 (Isomorphic Strings)
- 206.反转链表 (Reverse Linked List)
- 217.存在重复元素 (Contains Duplicate)
- 219.存在重复元素 II (Contains Duplicate II)
- 225.用队列实现栈 (Implement Stack using Queues)
- 226.翻转二叉树 (Invert Binary Tree)
- 231.2 的幂 (Power of Two)
- 232.用栈实现队列 (Implement Queue using Stacks)
- 234.回文链表 (Palindrome Linked List)
- 237.删除链表中的节点 (Delete Node in a Linked List)
- 242.有效的字母异位词 (Valid Anagram)
- 258.各位相加 (Add Digits)
- 263.丑数 (Ugly Number)
- 268.缺失数字 (Missing Number)
- 278.第一个错误的版本 (First Bad Version)
- 283.移动零 (Move Zeroes)
- 290.单词规律 (Word Pattern)
- 303.区域和检索-数组不可变 (Range Sum Query - Immutable)
- 326.3 的幂 (Power of Three)
- 342.4 的幂 (Power of Four)
- 344.反转字符串 (Reverse String)
- 345.反转字符串中的元音字母 (Reverse Vowels of a String)
- 349.两个数组的交集 (Intersection of Two Arrays)
- 350.两个数组的交集(Intersection of Two Arrays II)
- 374.猜数字大小 (Guess Number Higher or Lower)
- 383.赎金信 (Ransom Note)
- 387.字符串中的第一个唯一字符 (First Unique Character in a String)
- 389.找不同 (Find the Difference)
- 412.Fizz Buzz
- 414.第三大的数(Third Maximum Number)
- 415.字符串相加 (Add Strings)
- 448.找到所有数组中消失的数字 (Find All Numbers Disappeared in an Array)
- 455.分发饼干 (Assign Cookies)
- 461.汉明距离 (Hamming Distance)
- 463.岛屿的周长 (Island Perimeter)
- 476.数字的补数 (Number Complement)
- 485.最大连续 1 的个数 (Max Consecutive Ones)
- 496.下一个更大元素 I (Next Greater Element I)
- 500.键盘行 (Keyboard Row)
- 504.七进制数 (Base 7)
- 506.相对名次 (Relative Ranks)
- 509.斐波那契数列 (Fibonacci Number)
- 520.检测大写字母 (Detect Capital)
- 541.反转字符串 II (Reverse String II)
- 551.学生出勤记录 I (Student Attendance Record I)
- 557.反转字符串中的单词 III (Reverse Words in a String III)
- 561.数组拆分 I (Array Partition I)
- 575.分糖果 (Distribute Candies)
- 581.最短无序连续子数组 (Shortest Unsorted Continuous Subarray)
- 599.两个列表的最小索引总和 (Minimum Index Sum of Two Lists)
- 617.合并二叉树 (Merge Two Binary Trees)
- 645.错误的集合 (Set Mismatch)
- 657.机器人能否返回原点 (Robot Return to Origin)
- 682.棒球比赛 (Baseball Game)
- 693.交替位二进制数 (Binary Number with Alternating Bits)
- 703.数据流中的第 K 大元素 (Kth Largest Element in a Stream)
- 704.二分查找 (Binary Search)
- 705.设计哈希集合 (Design HashSet)
- 706.设计哈希映射 (Design HashMap)
- 709.转换成小写字母(To Lower Case)
- 728.自除数 (Self Dividing Numbers)
- 744.寻找比目标字母大的最小字母 (Find Smallest Letter Greater Than Target)
- 771.宝石与石头 (Jewels and Stones)
- 796.旋转字符串 (Rotate String)
- 804.唯一摩尔斯密码词(Unique Morse Code Words)
- 806.写字符串需要的行数 (Number of Lines To Write String)
- 811.子域名访问计数 (Subdomain Visit Count)
- 819.最常见的单词(Most Common Word)
- 821.字符的最短距离 (Shortest Distance to a Character)
- 832.翻转图像 (Flipping an Image)
- 844.比较含退格的字符串 (Backspace String Compare)
- 852.山脉数组的峰顶索引 (Peak Index in a Mountain Array)
- 860.柠檬水找零 (Lemonade Change)
- 868.二进制间距 (Binary Gap)
- 884.两句话中的不常见单词 (Uncommon Words from Two Sentences)
- 888.公平的糖果交换 (Fair Candy Swap)
- 905.按奇偶排序数组 (Sort Array By Parity)
- 917.仅仅反转字母 (Reverse Only Letters)
- 922.按奇偶排序数组 II (Sort Array By Parity II)
- 925.长按键入 (Long Pressed Name)
- 933.最近的请求次数 (Number of Recent Calls)
- 938.二叉搜索树的范围和 (Range Sum of BST)
- 941.有效的山脉数组 (Valid Mountain Array)
- 942.增减字符串匹配 (DI String Match)
- 961.重复 N 次的元素 (N-Repeated Element in Size 2N Array)
- 977.有序数组的平方 (Squares of a Sorted Array)
- 985.查询后的偶数和 (Sum of Even Numbers After Queries)
- 989.数组形式的整数加法 (Add to Array-Form of Integer)
- 1009.十进制整数的反码 (Complement of Base 10 Integer)
- 1010.总持续时间可被 60 整除的歌曲 (Pairs of Songs With Total Durations Divisible by 60)
- 1021.删除最外层的括号 (Remove Outermost Parentheses)
- 1046.最后一块石头的重量 (Last Stone Weight)
- 1047.删除字符串中的所有相邻重复项 (Remove All Adjacent Duplicates In String)
- 1051.高度检查器 (Height Checker)
- 1078.Bigram 分词 (Occurrences After Bigram)
- 1089.复写零 (Duplicate Zeros)
- 1108.IP 地址无效化(Defanging an IP Address)
- 1122.数组的相对排序(Relative Sort Array)
- 1154.一年中的第几天 (Day of the Year)
- 1160.拼写单词 (Find Words That Can Be Formed by Characters)
- 1170.比较字符串最小字母出现频次 (Compare Strings by Frequency of the Smallest Character)
- 1185.一周中的第一天 (Day_of_the_Week)
- 1189."气球"的最大数量 (Maximum Number of Balloons)
- 1200.最小绝对差 (Minimum Absolute Difference)
- 1207.独一无二的出现次数 (Unique Number of Occurrences)
- 1221.分割平衡字符串 (Split a String in Balanced Strings)
- 1252.奇数值单元格的数目 (Cells with Odd Values in a Matrix)
- 1281.整数的各位积和之差 (Subtract the Product and Sum of Digits of an Integer)
- 1287.有序数组中出现次数超过 25%的元素 (Element Appearing More Than 25% In Sorted Array)
- 1290.二进制链表转整数(Convert Binary Number in a Linked List to Integer)
- 1295.统计位数为偶数的数字 (Find Numbers with Even Number of Digits)
- 1299.将每个元素替换为右侧最大元素 (Replace Elements with Greatest Element on Right Side)
- 1304.和为零的 N 个唯一整数 (Find N Unique Integers Sum up to Zero)
- 1309.解码字母到整数映射 (Decrypt String from Alphabet to Integer Mapping)
- 1313.解压缩编码列表 (Decompress Run-Length Encoded List)
- 1317.将整数转换为两个无零整数的和 (Convert Integer to the Sum of Two No-Zero Integers)
- 1323.6 和 9 组成的最大数字(Maximum 69 Number)
- 1331.数组序号转换 (Rank Transform of an Array)
- 1337.方阵中战斗力最弱的 K 行 (The K Weakest Rows in a Matrix)
- 1342.将数字变成 0 的操作次数(Number of Steps to Reduce a Number to Zero)
- 1346.检查整数及其两倍数是否存在 (Check If N and Its Double Exist)
- 1351.统计有序矩阵中的负数 (Count Negative Numbers in a Sorted Matrix)
- 1356.根据数字二进制下 1 的数目排序 (Sort Integers by The Number of 1 Bits)
- 1360.日期之间隔几天 (Number of Days Between Two Dates)
- 1365.有多少小于当前数字的数字 (How Many Numbers Are Smaller Than the Current Number)
- 1370.上下升降字符串 (Increasing Decreasing String)
- 1374.生成每种字符都是奇数个的字符串 (Generate a String With Characters That Have Odd Counts)
- 1380.矩阵中的幸运数 (Lucky Numbers in a Matrix)
- 1385.两个数组间的距离值(Find the Distance Value Between Two Arrays)
- 1389.按既定顺序创建目标数组(Create Target Array in the Given Order)
- 1394.找出数组中的幸运数 (Find Lucky Integer in an Array)
- 1399.统计最大组的数目 (Count Largest Group)
- 1413.逐步求和得到正数的最小值 (Minimum Value to Get Positive Step by Step Sum)
- 1431.拥有最多糖果的孩子 (Kids With the Greatest Number of Candies)
- 1436.旅行终点站 (Destination City)
- 1441.用栈操作构建数组(Build an Array With Stack Operations)
- 1446.连续字符(Consecutive Characters)
- 1450.在既定时间做作业的学生人数(Number of Students Doing Homework at a Given Time)
- 1455.检查单词是否为句中其他单词的前缀
- 1460.通过翻转子数组使两个数组相等 (Make Two Arrays Equal by Reversing Sub-arrays)
- 1464.数组中两元素的最大乘积(Maximum Product of Two Elements in an Array)
- 1470.重新排列数组 (Shuffle the Array)
- 1475.商品折扣后的最终价格 (Final Prices With a Special Discount in a Shop)
- 1480.一堆数组的动态和 (Running Sum of 1d Array)
- 1486.数组异或操作(XOR Operation in an Array)
- 1491.去掉最低工资和最高工资后的平均工资值(Average Salary Excluding the Minimum and Maximum Salary)
- 1496.判断路径是否想交 (Path Crossing)
- 1502.判断能否形成等差数列 (Can Make Arithmetic Progression From Sequence)
- 1507.转变日期格式(Reformat Date)
- 1512.好数对的数目(Number of Good Pairs)
- 1518.换酒问题 (Water Bottles)
- 1528.重新排列字符串 (Shuffle String)
- 1539.第 k 个缺失的正整数 (Kth Missing Positive Number)
- 1544.整理字符串 (Make The String Great)
- 1550.存在连续三个奇数的数组 (Three Consecutive Odds)
- 1556.千位分隔数(Thousand Separator)
- 1560.圆形赛道上经过次数最多的扇区 (Most Visited Sector in a Circular Track)
- 1572.矩阵对角线元素的和 (Matrix Diagonal Sum)
- 1588.所有奇数长度子数组的和 (Sum of All Odd Length Subarrays)
- 1598.文件夹操作日志搜集器 (Crawler Log Folder)
- 1603.设计停车系统(Design Parking System)
- 1614.括号的最大嵌套深度(Maximum Nesting Depth of the Parentheses)
- 1619.删除某些元素后的数组均值 (Mean of Array After Removing Some Elements)
- 1624.两个相同字符之间的最长子字符串 (Largest Substring Between Two Equal Characters)
- 1625.拆炸弹 (Defuse the Bomb)
- 1636.按照频率将数组升序排序(Sort Array by Increasing Frequency)
- 1640.能否连接形成数组 (Check Array Formation Through Concatenation)
- 1662.检查两个字符串数组是否相等 (Check If Two String Arrays are Equivalent)
- 1672.最富有客户的资产总量 (Richest Customer Wealth)
- 1684.统计一致字符串的数目 (Count the Number of Consistent Strings)
- 1678.设计 Goal 解析器 (Goal Parser Interpretation)
- 1688.比赛中的配对次数 (Count of Matches in Tournament)
- 1700.无法吃午餐的学生数量 (Number of Students Unable to Eat Lunch)
- 1704.判断字符串的两半是否相似 (Determine if String Halves Are Alike))
- 1716.计算力扣银行的钱 (Calculate Money in Leetcode Bank)
- 1732.找到最高海拔(Find the Highest Altitude)
- 1736.替换隐藏数字得到的最晚时间 (Latest Time by Replacing Hidden Digits)
- 1742.盒子中小球的最大数量(Maximum Number of Balls in a Box)
- 1768.交替合并字符串(Merge Strings Alternately)
- 1773.统计匹配检索规则的物品数量(Count Items Matching a Rule)
- 1790.仅执行一次字符串交换能否使两个字符串相等 (Check if One String Swap Can Make Strings Equal)
- 1796.字符串中第二大的数字(Second Largest Digit in a String)
- 1805.字符串中不同整数的数目(Number of Different Integers in a String)
- 1812.判断国际象棋棋盘中一个格子的颜色(Determine Color of a Chessboard Square)
- 1816.截断句子(Truncate Sentence)
- 1822.数组元素积的符号(Sign of the Product of an Array)
- 1827.最少操作使数组递增(Minimum Operations to Make the Array Increasing)
- 1832.判断句子是否为全字母句(Check if the Sentence Is Pangram)
- 1844.将所有数字用字符替换(Replace All Digits with Characters)
- 5456.在区间范围内统计奇数数目 (Count Odd Numbers in an Interval Range)
- 5475.统计好三元组 (Count Good Triplets)
- 5657.唯一元素的和 (Sum of Unique Elements)
- 剑指 offer03.数组中重复的数字
- 剑指 offer04.二维数组中的查找
- 剑指 offer05.替换空格
- 剑指 offer06.从头到尾打印链表
- 剑指 offer09.用两个栈实现队列
- 剑指 offer11.旋转数组的最小数字
- 剑指 offer15.二进制中 1 的个数
- 剑指 offer17.打印从 1 到最大的 n 位数
- 剑指 offer18.删除链表的节点
- 剑指 offer21.调整数组顺序使奇数位于偶数前面
- 剑指 offer22.链表中倒数第 k 个节点
- 剑指 offer24.反转链表
- 剑指 offer25.合并两个排序的链表
- 剑指 Offer27.二叉树的镜像
- 剑指 offer30.包含 min 函数的栈
- 剑指 offer39.数组中出现次数超过一半的数字
- 剑指 offer40.最小的 k 个数
- 剑指 offer50.第一个只出现一次的字符
- 剑指 offer53-I.在排序数组中查找数字 I
- 剑指 offer53-II.在 0~n-1 中缺失的数字
- 剑指 offer57.和为 s 的两个数字
- 剑指 offer58-I.翻转单词顺序
- 剑指 offer58-II.左旋转字符串
- 剑指 offer59-I.滑动窗口的最大值
- 剑指 offer62.圆圈中最后剩下的数字
- k-01.01.判定字符是否唯一
- k-01.02.判定是否互为字符重排
- k-01.03.URL 化
- k-01.06.字符串压缩
- k-02.01.移除重复节点
- k-02.02.返回倒数第 k 个节点
- k-02.03.删除中间节点
- k-03.01.三合一
- k-03.02.栈的最小值
- k-03.04.化栈为队
- k-05.07.配对交换
- k-08.03.魔术索引
- k-10.01.合并排序的数组
- k-10.05.稀疏数组搜索
- k-17.04.消失的数字
- k-17.10.主要元素
- LCP_01.猜数字
- LCP_06.拿硬币
- LCP_17.速算机器人
medium
- 2.两数相加 (Add Two Numbers)
- 3.无重复字符的最长子串(Longest Substring Without Repeating Characters)
- 11.盛水最多的容器(Container With Most Water)
- 15.三数之和 (3Sum)
- 17.电话号码的字母组合(Letter Combinations Of A Phone Number)
- 19.删除链表的倒数第 N 个节点 (Remove Nth Node From End Of List)
- 24.两两交换链表中的节点 (Swap Nodes in Pairs)
- 33.搜索旋转排序数组 (Search in Rotated Sorted Array)
- 34.在排序数组中查找元素的第一个和最后一个位置(Find First and Last Position of Element in Sorted Array)
- 36.有效的数独 (Valid Sudoku)
- 49.字母异位词分组 (Group Anagrams)
- 56.合并区间 (Merge Intervals)
- 61.旋转链表 (Rotate List)
- 75.颜色分类 (Sort Colors)
- 82.删除排序链表中的重复元素 II (Remove Duplicates from Sorted List II)
- 86.分隔链表 (Partition List)
- 94.二叉树的中序遍历 (Binary Tree Inorder Traversal)
- 102.二叉树的层序遍历(Binary Tree Level Order Traversal)
- 137.只出现一次的数字 II (Single Number II)
- 144.二叉树的前序遍历 (Binary Tree Preorder Traversal)
- 145.二叉树的后序遍历(Binary Tree Postorder Traversal)
- 151.翻转字符串里的单词 (Reverse Words in a String)
- 165.比较版本号(Compare Version Numbers)
- 187.重复的 DNA 序列 (Repeated DNA Sequences)
- 215.数组中的第 K 个最大元素 (Kth Largest Element in an Array)
- 228.汇总区间 (Summary Ranges)
- 260.只出现一次的数字 III (Single Number III)
- 287.寻找重复数 (Find the Duplicate Number)
- 347.前 K 个高频元素 (Top K Frequent Elements)
- 380.常数时间插入、删除和获取随机元素 (Insert Delete GetRandom O(1))
- 384.打乱数组 (Shuffle an Array)
- 442.数组中重复的数据(Find All Duplicates in an Array)
- 533.TinyURL 的加密与解密 (Encode and Decode TinyURL)
- 622.设计循环队列 (Queue Circular)
- 628.三个数的最大乘积 (Maximum Product of Three Numbers)
- 707.设计链表(Design Linked List)
- 739.每日温度 (Daily Temperatures)
- 807.保持城市天际线 (Max Increase to Keep City Skyline)
- 912.排序数组 (Sort an Array)
- 986.区间列表的交集 (Interval List Intersections)
- 1282.用户分组 (Group the People Given the Group Size They Belong To)
- 1379.找出克隆二叉树中的相同节点 (Find a Corresponding Node of a Binary Tree in a Clone of That Tree)
- 1410.HTML 实体解析器 (HTML Entity Parser)
- 1476.子矩阵查询 (Subrectangle Queries)
- 1551.使数组中所有元素相等的最小操作数 (Minimum Operations to Make Array Equal)
- 1833.雪糕的最大数量(Maximum Ice Cream Bars)
- 5476.找出数组游戏的赢家 (Find the Winner of an Array Game)
- 剑指 offer64.求 1+2+...+n
- k-16.01.交换数字