Skip to content

JMing15/LeetCode-Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

LeetCode by Cpp

[LeetCode Online Judge] (https://leetcode.com/) is a website containing many algorithm questions. Most of them are real interview questions of Google, Facebook, LinkedIn, Apple, etc. This repo shows my solutions by Cpp. Please feel free to reference and STAR to support this repo, thank you!

Data Structures

标识了 ✅ 的专题是完成所有题目了的,没有标识的是还没有做完所有题目的

算法

一.目录

# Tile Solution Acceptance Difficulty Frequency
0001 Two Sum GO 45.1% 简单 #
0002 Add Two Numbers GO 31.8% 中等 #
0003 Longest Substring Without Repeating Characters GO 28.9% 中等 #
0006 ZigZag Conversion GO 33.3% 中等 #
0007 Reverse Integer GO 25.5% 简单 #
0009 Palindrome Number GO 45.0% 简单 #
0011 Container With Most Water GO 46.8% 中等 #
0013 Roman to Integer GO 53.3% 简单 #
0017 Letter Combinations of a Phone Number GO 42.0% 中等 #
0020 Valid Parentheses GO 37.3% 简单 #
0021 Merge Two Sorted Lists GO 49.0% 简单 #
0022 Generate Parentheses GO 58.6% 中等 #
0026 Remove Duplicates from Sorted Array GO 42.0% 简单 #
0027 Remove Element GO 45.6% 简单 #
0031 Next Permutation GO 31.1% 中等 #
0033 Search in Rotated Sorted Array GO 33.2% 中等 #
0035 Search Insert Position GO 41.2% 简单 #
0039 Combination Sum GO 52.3% 中等 #
0040 Combination Sum II GO 44.8% 中等 #
0046 Permutations GO 59.2% 中等 #
0047 Permutations II GO 43.5% 中等 #
0048 Rotate Image GO 50.7% 中等 #
0054 Spiral Matrix GO 31.5% 中等 #
0056 Merge Intervals GO 36.7% 中等 #
0057 Insert Interval GO 31.8% Hard #
0059 Spiral Matrix II GO 48.5% 中等 #
0060 Permutation Sequence GO 34.8% 中等 #
0066 Plus One GO 41.7% 简单 #
0073 Set Matrix Zeroes GO 40.9% 中等 #
0074 Search a 2D Matrix GO 35.3% 中等 #
0077 Combinations GO 51.3% 中等 #
0078 Subsets GO 55.2% 中等 #
0079 Word Search GO 33.2% 中等 #
0080 Remove Duplicates from Sorted Array II GO 41.4% 中等 #
0094 二叉树的中序遍历 GO 70.5% 中等 #
0121 Best Time to Buy and Sell Stock GO 49.5% 简单 #
0141 环形链表 GO 46.9% 简单 #
0151 Reverse Words in a String GO 18.5% 中等 #
0152 Maximum Product Subarray GO 30.4% 中等 #
0155 Min Stack GO 39.7% 简单 #
0166 Fraction to Recurring Decimal GO 25.3% 中等 #
0167 Two Sum II - Input array is sorted GO 51.9% 简单 #
0168 Excel Sheet Column Title GO 29.9% 简单 #
0169 多数元素 GO 54.9% 简单 #
0171 Majority Element GO 52.8% 简单 #
0187 Repeated DNA Sequences GO 37.4% 中等 #
0190 Reverse Bits GO 41.4% 简单 #
0191 Number of 1 Bits GO 45.8% 简单 #
0198 SuHouse Robberbsets GO 41.4% 简单 #
0201 Bitwise AND of Numbers Range GO 36.8% 中等 #
0206 Reverse Linked List GO 59.8% 简单 #
0231 Power of Two GO 42.6% 简单 #
0260 Single Number III GO 58.9% 中等 #
0268 Missing Number GO 49.7% 简单 #
0300 最长上升子序列 GO 43.9% 中等 #
0318 Maximum Product of Word Lengths GO 49.7% 中等 #
0338 Counting Bits GO 66.2% 中等 #
0342 Power of Four GO 40.9% 简单 #
0389 Find the Difference GO 54.0% 简单 #
0397 Integer Replacement GO 32.2% 中等 #
0695 岛屿的最大面积 GO 61.2% 中等 #
0836 矩形重叠 GO 48.6% 简单 #
1071 字符串的最大公因子 GO 58.2% 中等 #
1160 拼写单词 GO 68.3% 简单 #
---- ------------------------ ------ ---------- ---------- ----

分类

Array

# Tile Difficulty Time Space 收藏
1 Two Sum 简单
121 Best Time to Buy and Sell Stock 简单
167 Two Sum II - Input array is sorted 简单
1013 将数组分成和相等的三个部分 简单

String

# Tile Difficulty Time Space 收藏
151 Reverse Words in a String 中等
166 Fraction to Recurring Decimal 中等
187 Repeated DNA Sequences 中等
1071 字符串的最大公因子 简单
1160 拼写单词 简单

Linked List

# Tile Difficulty Time Space 收藏
141 环形链表 简单
206 Two Sum II - Input array is sorted 简单

Stack

# Tile Difficulty Time Space 收藏
155 Min Stack 简单

Tree

# Tile Difficulty Time Space 收藏
94 二叉树的中序遍历 中等

Dynamic Programming

# Tile Difficulty Time Space 收藏
78 Subsets 中等
152 Maximum Product Subarray 中等
198 House Robber 中等
300 最长上升子序列 中等

Backtracking

  • 排列问题Permutation:第46题、第47题、第60题、
  • 组合问题Combination:第17题、第39题、第40题、第77题
  • 四方向搜索问题。第79题
# Tile Difficulty Time Space 收藏
17 Letter Combinations of a Phone Number 中等
22 Generate Parentheses 中等
39 Combination Sum 中等
40 Combination Sum II 中等
46 Permutations 中等
47 Permutations II 中等
60 Permutation Sequence 中等
77 Combinations 中等
78 Subsets 中等
79 Word Search 中等

Depth-first Search

# Tile Difficulty Time Space 收藏
695 岛屿的最大面积 中等

Breadth-first Search

# Tile Difficulty Time Space 收藏
695 岛屿的最大面积 中等

Math

# Tile Difficulty Time Space 收藏
836 矩形重叠 简单

Bit Manipulation

  • 异或的特性。第136题。
x ^ 0 = x(136题)
x ^ x = 0(136题、389题) 
a ^ b = c => a ^ c = b => b ^ c => a (交换律)
a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c(结合律)(136题)
  • 构造特殊的mask,将特殊为设置为0或1

  • 有特殊意义的&位操作运算

x & 1 == 1or==0判断x的奇偶性,x&1>0为奇数
x &= (x-1) 将最低位(LSB)的1清零 (201题、231题、338题)
x & -x 得到最低位(LSB)的1
# Tile Difficulty Time Space 收藏
78 Subsets 中等
136 Single Number 简单
187 Repeated DNA Sequences 中等
190 Reverse Bits 简单
191 Number of 1 Bits 简单
201 Bitwise AND of Numbers Range 中等
232 Power of Two 简单
260 Single Number III 中等
268 Missing Number 简单
318 Maximum Product of Word Lengths 中等
338 Counting Bits 中等
342 Power of Four 简单
389 Find the Difference 简单
397 Integer Replacement 中等

Union Find

# Tile Difficulty Time Space 收藏
547 Friend Circles 中等

Others

# Tile Difficulty Time Space 收藏
169 多数元素 简单

About

⭐⭐⭐进击的秋招之路⭐⭐⭐

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages