Repository for source codes of leetcode
Solve the algorithm problems leetcode.com provides.
The conventions used in the project are:
- package: converting last path of leetcode problem url to snake case
- class: Solution.java
- test: SolutionTest.java
ex)
url https://leetcode.com/problems/wildcard-matching
package io.lcalmsky.leetcode.wildcard_matching
class io.lcalmsky.leetcode.wildcard_matching.Solution
test io.lcalmsky.leetcode.wildcard_matching.SolutionTest
- 132 pattern
- 24 game
- 3sum
- 3sum with multiplicity
- 4sum
- 4sum ii
- accounts merge
- add binary
- add digits
- add one row to tree
- add strings
- add two number ii
- add two numbers
- advantage shuffle
- all elements in two binary search trees
- all nodes distance k in binary tree
- all paths from source to target
- arithmetic slices
- array nesting
- asteroid collision
- average of levels in binary tree
- backspace string compare
- balanced binary tree
- base 7
- basic calculator ii
- beautiful arrangement
- best time to buy and sell stock
- best time to buy and sell stock ii
- best time to buy and sell stock iii
- best time to buy and sell stock with cooldown
- best time to buy and sell stock with transaction fee
- binary number with alternating bits
- binary search
- binary tree inorder traversal
- binary tree level order traversal
- binary tree level order traversal ii
- binary tree maximum path sum
- binary tree postorder traversal
- binary tree preorder traversal
- binary tree pruning
- binary tree right side view
- binary tree zigzag level order traversal
- bitwise and of numbers range
- boats to save people
- break a palindrome
- brick wall
- broken calculator
- burst balloons
- bus routes
- can place flowers
- candy
- car pooling
- champagne tower
- cherry pickup
- cherry pickup ii
- climbing stairs
- coin change
- coin change 2
- combination sum
- combination sum ii
- combination sum iii
- combination sum iv
- combinations
- complement of base 10 integer
- complex number multiplication
- consecutive characters
- construct binary search tree from preorder traversal
- construct binary tree from inorder and postorder traversal
- construct binary tree from preorder and inorder traversal
- container with most water
- contains duplicates
- contiguous array
- convert a number to hexadecimal
- convert binary number in a linked list to integer
- convert bst to greater tree
- convert sorted array to binary search tree
- count binary strings
- count complete tree nodes
- count different palindromic subsequences
- count of smaller numbers after self
- count primes
- counting bits
- course schedule ii
- course schedule iii
- cousins in binary tree
- daily temparatures
- decode string
- deepest leaves sum
- delete and earn
- delete node in a bst
- delete operation for two strings
- design add and search words data structure
- design hashset
- detect capital
- diagonal traverse
- diameter of binary tree
- distinct subsequences
- divide two integers
- domino and tromino tiling
- dungeon game
- edit distance
- evaluate division
- excel sheet column number
- excel sheet column title
- fibonacci number
- find a corresponding node of a binary tree in a clone of that tree
- find all anagram in a string
- find all duplicates in an array
- find all numbers disappeared in an array
- find bottom left tree value
- find duplicate subtrees
- find eventual safe states
- find first and last position of element in sorted array
- find k closest elements
- find k pairs with smallest sums
- find k th smallest pair distance
- find largest value in each tree row
- find minimum in rotated sorted array
- find minimum in rotated sorted array ii
- find peak element
- find the duplicate number
- find the town judge
- first missing positive
- first unique character in a string
- flatten binary tree to linked list
- flipping an image
- flood fill
- foursum ii
- freedom trail
- friend circles
- game of life
- gas station
- generate parentheses
- group anagrams
- hamming distance
- hand of straights
- happy number
- house robber
- house robber ii
- house robber iii
- implement strstr
- implement trie
- increasing order search tree
- increasing subsequences
- increasing triplet subsequence
- insert delete getrandom o1
- insert interval
- insert into a binary search tree
- insertion sort list
- integer break
- integer to roman
- interleaving string
- intersection of two arrays ii
- invert binary tree
- is subsequence
- island perimeter
- isomorphic strings
- iterator for combination
- jewels and stones
- jump game
- jump game ii
- jump game iii
- jump game iv
- k closest points to origin
- k th smallest in lexicographical order
- keys and rooms
- knight probability in chessboard
- koko eating bananas
- kth largest element in a stream
- kth largest element in an array
- kth smallest element in a bst
- kth smallest element in a sorted matrix
- kth smallest number in multiplication table
- largest divisible subset
- largest number
- largest plus sign
- largest rectangle in histogram
- largest sum of averages
- last stone weight
- lemonade change
- letter combinations of a phone number
- lexicographical numbers
- lfu cache
- linked list cycle
- linked list cycle ii
- linked list random node
- logest substring without repeating characters
- longest common prefix
- longest consecutive sequence
- longest continuous increasing subsequence
- longest harmonious subsequence
- longest increasing path in a matrix
- longest increasing subsequence
- longest mountain in array
- longest palindrome
- longest palindromic subsequence
- longest palindromic substring
- longest repeating character replacement
- longest substring with at least k repeating characters
- longest turbulent subarray
- longest univalue path
- longest valid parentheses
- majority element
- majority element ii
- max area of island
- max number of k sum pairs
- max sum of rectangle no larger than k
- maximal rectangle
- maximal square
- maximize distance to closest person
- maximum average subarray i
- maximum binary tree
- maximum depth of binary tree
- maximum difference between node and ancestor
- maximum gap
- maximum length of n ary tree
- maximum length of repeated subarray
- maximum number of balloons
- maximum product of three numbers
- maximum product of word lengths
- maximum product subarray
- maximum subarray
- maximum width of binary tree
- maximum xor of two numbers in an array
- maxmimum length of pair chain
- maxmimum swap
- median of two sorted arrays
- merge intervals
- merge k sorted lists
- merge two binary trees
- merge two sorted lists
- middle of the linked list
- min cost climbing stairs
- minimize deviation in array
- minimum absolute difference
- minimum absolute different in a bst
- minimum ascii delete sum for two strings
- minimum cost to move chips to the same position
- minimum depth of binary tree
- minimum distance between bst nodes
- minimum domino rotations for equal row
- minimum genetic mutation
- minimum height trees
- minimum moves to equal array elements ii
- minimum number of arrows to burst balloons
- minimum path sum
- minimum size subarray sum
- minimum swaps to make sequences increasing
- minimum time difference
- minimum value to get positive step by step sum
- missing number
- monotone increasing digits
- most frequent subtree sum
- most profit assigning work
- move zeroes
- multiply strings
- my calendar ii
- n ary tree level order traversal
- n ary tree postorder traversal
- n ary tree preorder traversal
- n repeated element in size 2n array
- network delay time
- next greater element i
- next greater element ii
- next permutation
- non decreasing array
- non negative integers without consecutive ones
- non overlapping internvals
- nth magical number
- nth tribonacci number
- number complement
- number of 1 bits
- number of islands
- number of longest increasing subsequence
- odd even linked list
- open the lock
- pairs of songs with total durations divisible by 60
- palindrome linked list
- palindrome number
- palindrome partitioning
- palindrome substrings
- panlindrome pairs
- partition equal subset sum
- partition labels
- partition to k equal sum subsets
- pascals triangle
- pascals triangle ii
- patching array
- path sum
- path sum ii
- path sum iii
- pattern of 132
- perfect squares
- permutation in string
- permutation sequence
- permutations
- permutations ii
- populating next right pointers in each node
- positions of large groups
- power of four
- power of two
- predict the winner
- print binary tree
- product of array except self
- push dominoes
- queue reconstruction by height
- race car
- range addition ii
- range sum of bst
- range sum query 2d immutable
- range sum query mutable
- recover binary search tree
- rectangle area ii
- rectangle overlap
- regular expression matching
- remove all adjacent duplicates in string ii
- remove boxes
- remove covered intervals
- remove duplicate letters
- remove duplicates from sorted array
- remove duplicates from sorted array ii
- remove duplicates from sorted list
- remove duplicates from sorted list ii
- remove element
- remove invalid parentheses
- remove k digits
- remove linked list elements
- remove nth node from end of list
- reorder list
- reorganize string
- repeated substring pattern
- replace words
- reshape the matrix
- restore ip addresses
- reverse integer
- reverse linked list
- reverse linked list ii
- reverse nodes in k group
- reverse only letters
- reverse pairs
- reverse string
- reverse words in a string iii
- richest customer wealth
- robot bounded in circle
- robot return to origin
- roman to integer
- rotate array
- rotate function
- rotate list
- rotate string
- rotting oranges
- russian doll envelopes
- same tree
- score after flipping matrix
- score of parentheses
- search a 2d matrix
- search a 2d matrix ii
- search in a binary search tree
- search in rotated sorted array
- search in rotated sorted array ii
- search insert position
- sequential digits
- set matrix zeroes
- set mismatch
- shifting letters
- shortest distance to a character
- shortest path in binary matrix
- shortest path visiting all nodes
- shortest subarray with sum at least k
- shortest unsorted continuous subarray
- simplify path
- single element in a sorted array
- single number
- single number ii
- sliding window maximum
- slowest key
- smallest range covering elements from k lists
- smallest subtree with all the deepest nodes
- sort array by parity
- sort array by parity ii
- sort characters by frequency
- sort colors
- sort list
- spiral matrix
- spiral matrix ii
- split array into consecusive subsequence
- split array largest sum
- split linked list in parts
- stickers to spell word
- stone game iv
- strange printer
- student attendance record ii
- subarray product less than k
- subarray sum equals k
- subsets
- subsets ii
- subtree of another tree
- sudoku solver
- sum of left leaves
- sum of root to leaf binary numbers
- sum of square numbers
- sum root to leaf numbers
- summary ranges
- super ugly number
- surrounded regions
- swap node in pairs
- symmetric tree
- target sum
- task scheduler
- the k weakest rows in a matrix
- threesum
- threesum closest
- toeplitz matrix
- top k frequent elements
- top k frequent words
- total hamming distance
- transpose matrix
- trapping rain water
- trapping rain water ii
- triangle
- trim a binary search tree
- two city scheduling
- two keys keyboard
- two sum
- two sum ii input array is sorted
- two sum iv input is a bst
- ugly number ii
- unique binary search trees
- unique binary search trees ii
- unique paths
- unique paths ii
- valid anagram
- valid mountain array
- valid palindrome ii
- valid parentheses
- valid parenthesis string
- valid perfect square
- valid sudoku
- valid triangle number
- validate binary search tree
- validate stack sequences
- verify preorder serialization of a binary tree
- wiggle subsequence
- wildcard matching
- word break
- word pattern
- word search
- zeroone matrix
- zigzag conversion