- 001 Two Sum
- 002 Add Two Numbers
- 003 Longest Substring Without Repeating Characters
- 005 Longest Palindromic Substring
- 006 ZigZag Conversion
- 007 Reverse Integer
- 009 Palindrome Number
- 010 Regular Expression Matching
- 011 Container With Most Water
- 013 Roman to Integer
- 015 3Sum
- 016 3Sum Closest
- 017 Letter Combinations of a Phone Number
- 019 Remove Nth Node From End of List
- 020 Valid Parentheses
- 021 Merge Two Sorted Lists
- 022 Generate Parentheses
- 023 Merge k Sorted Lists
- 024 Swap Nodes in Pairs
- 025 Reverse Nodes in k-Group
- 026 Remove Duplicates from Sorted Array
- 027 Remove Element
- 028 Implement strStr()
- 029 Divide Two Integers
- 031 Next Permutation
- 032 Longest Valid Parentheses
- 033 Search in Rotated Sorted Array
- 034 Search for a Range
- 035 Search Insert Position
- 036 Valid Sudoku
- 037 Sudoku Solver
- 038 Count and Say
- 039 Combination Sum
- 040 Combination Sum II
- 041 First Missing Positive
- 042 Trapping Rain Water
- 043 Multiply Strings
- 044 Wildcard Matching
- 045 Jump Game II
- 046 Permutations
- 047 Permutations II
- 048 Rotate Image
- 049 Group Anagrams
- 050 Pow(x, n)
- 051 N-Queens
- 052 N-Queens II
- 053 Maximum Subarray
- 054 Spiral Matrix
- 055 Jump Game
- 056 Merge Intervals
- 057 Insert Interval
- 058 Length of Last Word
- 059 Spiral Matrix II
- 060 Permutation Sequence
- 061 Rotate List
- 062 Unique Paths
- 063 Unique Paths II
- 064 Minimum Path Sum
- 065 Valid Number
- 066 Plus One
- 067 Add Binary
- 069 Sqrt(x)
- 070 Climbing Stairs
- 071 Simplify Path
- 072 Edit Distance
- 073 Set Matrix Zeroes
- 074 Search a 2D Matrix
- 075 Sort Colors
- 076 Minimum Window Substring
- 077 Combinations
- 078 Subsets
- 079 Word Search
- 080 Remove Duplicates from Sorted Array II
- 081 Search in Rotated Sorted Array II
- 082 Remove Duplicates from Sorted List II
- 083 Remove Duplicates from Sorted List
- 084 Largest Rectangle in Histogram
- 085 Maximal Rectangle
- 086 Partition List
- 087 Scramble String
- 088 Merge Sorted Array
- 090 Subsets II
- 091 Decode Ways
- 092 Reverse Linked List II
- 093 Restore IP Addresses
- 094 Binary Tree Inorder Traversal
- 096 Unique Binary Search Trees
- 098 Validate Binary Search Tree
- 100 Same Tree
- 101 Symmetric Tree
- 102 Binary Tree Level Order Traversal
- 103 Binary Tree Zigzag Level Order Traversal
- 104 Maximum Depth of Binary Tree
- 105 Construct Binary Tree from Preorder and Inorder Traversal
- 110 Balanced Binary Tree
- 111 Minimum Depth of Binary Tree
- 112 Path Sum
- 113 Path Sum II
- 114 Flatten Binary Tree to Linked List
- 116 Populating Next Right Pointers in Each Node
- 117 Populating Next Right Pointers in Each Node II
- 118 Pascal's Triangle
- 119 Pascal's Triangle II
- 121 Best Time to Buy and Sell Stock
- 122 Best Time to Buy and Sell Stock II
- 123 Best Time to Buy and Sell Stock III
- 124 Binary Tree Maximum Path Sum
- 125 Valid Palindrome
- 133 Clone Graph
- 136 Single Number
- 138 Copy List with Random Pointer
- 139 Word Break
- 143 Reorder List
- 144 Binary Tree Preorder Traversal
- 145 Binary Tree Postorder Traversal
- 146 LRU Cache
- 151 Reverse Words in a String
- 152 Maximum Product Subarray
- 153 Find Minimum in Rotated Sorted Array
- 155 Min Stack
- 162 Find Peak Element
- 167 Two Sum II - Input array is sorted
- 169 Majority Element
- 189 Rotate Array
- 198 House Robber
- 199 Binary Tree Right Side View
- 200 Number of Islands
- 204 Count Primes
- 206 Reverse Linked List
- 207 Course Schedule
- 208 Implement Trie (Prefix Tree)
- 209 Minimum Size Subarray Sum
- 210 Course Schedule II
- 211 Add and Search Word - Data structure design
- 213 House Robber II
- 217 Contains Duplicate
- 219 Contains Duplicate II
- 222 Count Complete Tree Nodes
- 224 Basic Calculator
- 227 Basic Calculator II
- 231 Power of Two
- 236 Lowest Common Ancestor of a Binary Tree
- 237 Delete Node in a Linked List
- 238 Product of Array Except Self
- 257 Binary Tree Paths
- 258 Add Digits
- 263 Ugly Number
- 268 Missing Number
- 270 Closest Binary Search Tree Value
- 273 Integer to English Words
- 278 First Bad Version
- 282 Expression Add Operators
- 283 Move Zeroes
- 287 Find the Duplicate Number
- 290 Word Pattern
- 292 Nim Game
- 295 Find Median from Data Stream
- 297 Serialize and Deserialize Binary Tree
- 300 Longest Increasing Subsequence
- 301 Remove Invalid Parentheses
- 303 Range Sum Query - Immutable
- 304 Range Sum Query 2D - Immutable
- 312 Burst Balloons
- 327 Count of Range Sum
- 322 Coin Change
- 329 Longest Increasing Path in a Matrix
- 332 Reconstruct Itinerary
- 334 Increasing Triplet Subsequence
- 336 Palindrome Pairs
- 337 House Robber III
- 341 Flatten Nested List Iterator
- 342 Power of Four
- 344 Reverse String
- 347 Top K Frequent Elements
- 349 Intersection of Two Arrays
- 350 Intersection of Two Arrays II
- 377 Combination Sum IV
- 383 Ransom Note
- 387 First Unique Character in a String
- 389 Find the Difference
- 393 UTF-8 Validation
- 398 Random Pick Index
- 405 Convert a Number to Hexadecimal
- 414 Third Maximum Number
- 415 Add Strings
- 437 Path Sum III
- Find All Anagrams in a String
- 442 Find All Duplicates in an Array
- 443 String Compression
- 448 Find All Numbers Disappeared in an Array
- 463 Island Perimeter
- 477 Total Hamming Distance
- 485 Max Consecutive Ones
- 495 Teemo Attacking
- 498 Diagonal Traverse
- 523 Continuous Subarray Sum
- 525 Contiguous Array
- 532 K-diff Pairs in an Array
- 543 Diameter of Binary Tree
- 547 Friend Circles
- 560 Subarray Sum Equals K
- 561 Array Partition I
- 565
- 566 Reshape the Matrix
- 567 Permutation in String
- 581 Shortest Unsorted Continuous Subarray
- 621 Task Scheduler
- 628 Maximum Product of Three Numbers
- 636 Exclusive Time of Functions
- 643 Maximum Average Subarray I
- 654 Maximum Binary Tree
- 657 Judge Route Circle
- 658 Find K Closest Elements
- 661 Image Smoother
- 665 Non-decreasing Array
- 670 Maximum Swap
- 675 Cut Off Trees for Golf Event
- 681 Next Closest Time
- 682 Baseball Game
- 684 Redundant Connection
- 686 Repeated String Match
- 689 Maximum Sum of 3 Non-Overlapping Subarrays
- 695 Max Area of Island
- 697 Degree of an Array
- 714 Best Time to Buy and Sell Stock with Transaction Fee
- 717 1-bit and 2-bit Characters
- 724 Find Pivot Index
- 728 Self Dividing Numbers
- 733 Flood Fill
- 734 Sentence Similarity
- 735 Asteroid Collision
- 737 Sentence Similarity II
- 738 Monotone Increasing Digits
- 739 Daily Temperatures
- 740 Delete and Earn
- 745 Find Smallest Letter Greater Than Target
- 747 Min Cost Climbing Stairs
- 748 Largest Number At Least Twice of Others
- 749 Shortest Completing Word
- 753 Open the Lock
- 762 Prime Number of Set Bits in Binary Representation
- 763 Partition Labels
- 764 Largest Plus Sign
- 766 Toeplitz Matrix
- 767 Reorganize String
- 769 Max Chunks To Make Sorted
- 809 Expressive Words
- 811 Subdomain Visit Count
Q: What is LZS
? It almost appears inside all files (like js, cpp)?
A: Briefly speaking, that is an environment variable defined in my System. For unix/linux, you can add a command export LZS='true'
in ~/.bashrc
such that process.env.LZS
evaluates to true
rather than undefined.
The purpose of defining such a variable is to ensure some piece of code can only work in my computer and does not work in Leetcode server environment. In other words, some tests can work locally but have nothing to do with Leetcode server.
Take 006/main.js as an example.
if (process.env.LZS) { // local test
const assert = require('chai').assert
assert.strictEqual(convert('PAYPALISHIRING', 3), 'PAHNAPLSIIGYIR')
assert.strictEqual(convert('0123456789', 5), '0817926354')
assert.strictEqual(convert('0123456789', 1), '0123456789')
assert.strictEqual(convert('0123456789', 2), '0246813579')
assert.strictEqual(convert('0123456', 2000), '0123456')
}
As you can see, the function of this code works as some tests. This piece of code would not run on Leetcode server/judger. So you don't have to worry this code would cause Time Limited Exceeded
(since some tests would consume quite a long time).