Pattern
Array
A compact view of archive entries grouped by recurring technique.
373 entries
373 entries tagged as Array.
15.04.2026
easy2515. Shortest Distance to Target String in a Circular Array
Distance to target
28.03.2026
hard2573. Find the String with LCP
Build string from longest common prefixes matrix
27.03.2026
easy2946. Matrix Similarity After Cyclic Shifts
Shift rows k times left and right
26.03.2026
hard3548. Equal Sum Grid Partition II
Cut matrix in half sums, can remove one cell
25.03.2026
medium3546. Equal Sum Grid Partition I
Split matrix to equal sums
24.03.2026
medium2906. Construct Product Matrix
Product of other cells in a matrix
23.03.2026
medium1594. Maximum Non Negative Product in a Matrix
Max product path right-down
22.03.2026
easy1886. Determine Whether Matrix Can Be Obtained By Rotation
Rotate matrix
20.03.2026
medium3567. Minimum Absolute Difference in Sliding Submatrix
Mid diffs in k k submatrices
19.03.2026
medium3212. Count Submatrices With Equal Frequency of X and Y
Count prefix freq X == freq Y
18.03.2026
medium3070. Count Submatrices with Top-Left Element and Sum Less Than k
Count prefix sums less than K
17.03.2026
medium1727. Largest Submatrix With Rearrangements
Max area of binary matrix, swap columns
16.03.2026
medium1878. Get Biggest Three Rhombus Sums in a Grid
Top 3 rhombus sums
10.03.2026
hard3130. Find All Possible Stable Binary Arrays II
array to make with z zeros, o ones, l repeats
04.08.2026
easy1582. Special Positions in a Binary Matrix
Count single 1-row-column
02.03.2026
medium1536. Minimum Swaps to Arrange a Binary Grid
Min rows swaps to zero above diagonal
28.02.2026
medium1680. Concatenation of Consecutive Binary Numbers
Concat binaries 1..n
06.02.2026
medium3634. Minimum Removals to Balance Array
Min removals to make min k not less than max window
05.02.2026
easy3379. Transformed Array
Shuffled list i+n[i]
03.02.2026
easy3637. Trionic Array I
Validate inc,dec,inc sequency
02.02.2026
hard3013. Divide an Array Into Subarrays With Minimum Cost II
Min sum of k splits at max d distance window
01.02.2026
easy3010. Divide an Array Into Subarrays With Minimum Cost I
Split on 2 min values
31.01.2026
easy744. Find Smallest Letter Greater Than Target
Larger letter in array
29.01.2026
medium2976. Minimum Cost to Convert String I
Min cost to convert string
28.01.2026
hard3651. Minimum Cost Path with Teleportations
Min cost to walk 2D grid with free teleports
24.01.2026
medium1877. Minimize Maximum Pair Sum in Array
Min max pair
23.01.2026
hard3510. Minimum Pair Removal to Sort Array II
Sort by removing min-sum pairs
22.01.2026
easy3507. Minimum Pair Removal to Sort Array I
Sort by removing lowest sum pairs
21.01.2026
medium3315. Construct the Minimum Bitwise Array II
Reverse operation x or (x+1)
20.01.2026
easy3314. Construct the Minimum Bitwise Array I
Reverse x | (x+1) operation on prime numbers
15.01.2026
medium2943. Maximize Area of Square Hole in Grid
Max square area after removing bars in a grid
11.01.2026
hard85. Maximal Rectangle
Max all-1 rectangle in 2D matrix stack
05.01.2026
medium1975. Maximum Matrix Sum
Max sum after multiply -1 adjacent cells
03.12.2026
hard1411. Number of Ways to Paint N × 3 Grid
Ways to color 3xN grid
02.01.2026
easy961. N-Repeated Element in Size 2N Array
Duplicate majority element
31.12.2025
hard1970. Last Day Where You Can Still Cross
Last day top connected to bottom in 2D matrix
30.12.2025
medium840. Magic Squares In Grid
Count 'magic' 3x3 squares
29.12.2025
medium756. Pyramid Transition Matrix
Can build a pyramid from transitions?
28.12.2025
easy1351. Count Negative Numbers in a Sorted Matrix
Count negatives in 2D sorted matrix
29.11.2025
easy3512. Minimum Operations to Make Array Sum Divisible by K
Sum % k
27.11.2025
medium3381. Maximum Subarray Sum With Length Divisible by K
Max sum of %k-length subarray
26.11.2025
hard2435. Paths in Matrix Whose Sum Is Divisible by K
Paths in 2D matrix %k
19.11.2025
easy2154. Keep Multiplying Found Values by Two
First original=original 2 not in array
14.11.2025
medium2536. Increment Submatrices by One
Increase matrix by query of rectangles of ones
12.11.2025
medium2654. Minimum Number of Operations to Make All Array Elements Equal to 1
Min steps to make all '1' by gcd
06.11.2025
medium3607. Power Grid Maintenance
Smallest in subgraph after turning some nodes off
02.11.2025
medium2257. Count Unguarded Cells in the Grid
Count unseen cells by rays from guards
01.11.2025
medium3217. Delete Nodes From Linked List Present in Array
Remove an array from linked list
31.10.2025
easy3289. The Two Sneaky Numbers of Digitville
Two extra numbers from 0..n
30.10.2025
hard1526. Minimum Number of Increments on Subarrays to Form a Target Array
Min +1 range increases to make target from zeros
28.10.2025
easy3354. Make Array Elements Equal to Zero
Places & directions that lead the simulation to all zeros
13.10.2025
medium2273. Find Resultant Array After Removing Anagrams
Dedup anagrams
12.10.2025
medium3539. Find Sum of Array Product of Magical Sequences
Product of all good subsequences and permutations
10.10.2025
medium3147. Taking Maximum Energy From the Mystic Dungeon
Max k-distant suffix sum
30.09.2025
medium2221. Find Triangular Sum of an Array
Triangle sum % 10
28.09.2025
easy976. Largest Perimeter Triangle
Max triangle perimeter from array of lengths window
19.09.2025
medium3484. Design Spreadsheet
Design Spreadsheet: setCell, resetCell, getValue(a+b)
16.09.2025
hard2197. Replace Non-Coprime Numbers in Array
Simulate gcd to lcm adjacent pair removal
13.09.2025
easy3541. Find Most Frequent Vowel and Consonant
Max freq vowels + consonants
09.09.2025
medium2327. Number of People Aware of a Secret
People knowing a secret at day n, keeping delay then spread and forget
06.09.2025
hard3495. Minimum Operations to Make Array Elements Zero
Sum query [a..b] of optimal pairwise /4 until range is zero
28.08.2025
medium3446. Sort Matrix by Diagonals
Sort bottom left and top right diagonals
25.08.2025
medium498. Diagonal Traverse
Matrix diagonal traversal
16.08.2025
easy1323. Maximum 69 Number
Bigger number by replacing 6 to 9
31.07.2025
medium898. Bitwise ORs of Subarrays
Uniq OR-subarrays
27.07.2025
easy2210. Count Hills and Valleys in an Array
Count hills and valleys
5.07.2025
easy1394. Find Lucky Integer in an Array
Max x == freq(x)
25.06.2025
hard2040. Kth Smallest Product of Two Sorted Arrays
K-th increasing product from two arrays search
24.06.2025
easy2200. Find All K-Distant Indices in an Array
Indices k-distant to key
19.06.2025
medium2294. Partition Array Such That Maximum Difference Is K
k-narrow subsequences
18.06.2025
medium2966. Divide Array Into Arrays With Max Difference
List of k-narrow tripplets
17.06.2025
hard3405. Count the Number of Arrays with K Matching Adjacent Elements
Combinations k equal siblings 1..m in [n] array
12.06.2025
easy3423. Maximum Difference Between Adjacent Elements in a Circular Array
Max abs sibling diff
31.05.2025
medium909. Snakes and Ladders
Shortest path bottom-top in zig-zag matrix with jumps
22.05.2025
medium3362. Zero Array Transformation III
Max removed queries still zero-fy an array
21.05.2025
medium73. Set Matrix Zeroes
Zero-fy rows and columns
20.05.2025
medium3355. Zero Array Transformation I
Can intersecting intervals decrease an array sweep
18.05.2025
hard1931. Painting a Grid With Three Different Colors
Ways to 3-color m n grid, no adjucents
17.05.2025
medium75. Sort Colors
Sort 0,1,2 array pointers
10.05.2025
medium2918. Minimum Equal Sum of Two Arrays After Replacing Zeros
Min equal array sum, fill zeros
06.05.2025
easy1920. Build Array from Permutation
n[n[i]]
24.04.2025
medium2799. Count Complete Subarrays in an Array
Subarrays having all uniqs pointers
21.04.2025
medium2145. Count the Hidden Sequences
Possible arrays from diff array and lo..hi
17.04.2025
easy2176. Count Equal and Divisible Pairs in an Array
Pairs a[i] == b[j], i j % k == 0
15.04.2025
hard2179. Count Good Triplets in an Array
Triplets in same order in both (0..n)-arrays
09.04.2025
easy3375. Minimum Operations to Make Array Values Equal to K
Count number bigger than k
08.04.2025
easy3396. Minimum Number of Operations to Make Elements in Array Distinct
Count removals 3-prefixes to deduplicate
07.04.2025
medium416. Partition Equal Subset Sum
Two equal sum subsets
26.03.2025
medium2033. Minimum Operations to Make a Uni-Value Grid
Min sum of differences of x times
19.03.2025
medium3191. Minimum Operations to Make Binary Array Elements Equal to One I
bits flips to make all 1 manipulation
15.03.2025
medium2560. House Robber IV
Min-max of non-adjucents in array search
13.03.2025
medium3356. Zero Array Transformation II
Min queries (l..r, v) to decrease nums by v to 0 sweep
06.03.2025
easy2965. Find Missing and Repeated Values
Missing and repeated in 1..n array
03.03.2025
medium2161. Partition Array According to Given Pivot
Partition around p
02.03.2025
easy2570. Merge Two 2D Arrays by Summing Values
Merge two ascending [key, value] lists
01.03.2025
easy2460. Apply Operations to an Array
If a[i] == a[i + 1], a[i] = 2, a[i + 1] = 0
16.02.2025
medium1718. Construct the Lexicographically Largest Valid Sequence
Construct array x = 1..n, a[i] = x, a[i + x] = x
02.02.2025
easy1752. Check if Array Is Sorted and Rotated
Is array sorted and rotated?
01.02.2025
easy3151. Special Array I
All siblings even-odd
31.01.2025
hard827. Making A Large Island
Max area after filling one empty 2D grid cell find
28.01.2025
medium2658. Maximum Number of Fish in a Grid
Largest region in 2D grid
25.01.2025
medium2948. Make Lexicographically Smallest Array by Swapping Elements
Sort by swapping ab, where abs(a - b) < limit
21.01.2025
medium2017. Grid Game
Maximum of minimized paths sum
20.01.2025
medium2661. First Completely Painted Row or Column
Index of the first filled row/column in 2D matrix
19.01.2025
hard407. Trapping Rain Water II
Trap the water in 2D height matrix
18.01.2025
hard1368. Minimum Cost to Make at Least One Valid Path in a Grid
Min undirected jumps to reach the end in grid
17.01.2025
medium2683. Neighboring Bitwise XOR
Can restore next-sibl-xored array?
16.01.2025
medium2425. Bitwise XOR of All Pairings
Xor of all pairs xors
14.01.2025
medium2657. Find the Prefix Common Array of Two Arrays
A[..i] and B[..i] intersections sizes
07.01.2025
easy1408. String Matching in an Array
All substrings
05.01.2025
medium2381. Shifting Letters II
Apply from..to, direction shifts to string chars sweep
03.01.2025
medium2270. Number of Ways to Split Array
Count splits left sum >= right sum sum
19.12.2024
medium769. Max Chunks To Make Sorted
Maximum independent chunks to merge-sort array
16.12.2024
easy3264. Final Array State After K Multiplication Operations I
Mutliply k minimums
12.12.2024
medium2558. Take Gifts From the Richest Pile
Sum after k-Sqrt of tops in array
09.12.2024
medium3152. Special Array II
Queries is all adjucents parity differ [i..j] pointers
29.11.2024
hard2577. Minimum Time to Visit a Cell In a Grid
Min time start-end 4-d travel in 2D matrix with waiting
28.11.2024
hard2290. Minimum Obstacle Removal to Reach Corner
Min removals to travel first-last in 2D grid
27.11.2024
medium3243. Shortest Distance After Road Addition Queries I
Query shortest paths after adding new edges
24.11.2024
medium1975. Maximum Matrix Sum
Max sum of 2D matrix after multiply by -1 adjacent cells
23.11.2024
medium1861. Rotating the Box
Rotate matrix and simulate the fall
22.11.2024
medium1072. Flip Columns For Maximum Number of Equal Rows
Max same-bit-rows after flipping columns in 01-2D matrix
21.11.2024
medium2257. Count Unguarded Cells in the Grid
Count unseen cells in 2D matrix with guards and walls
15.11.2024
medium1574. Shortest Subarray to be Removed to Make Array Sorted
Min subarray remove to make array sorted pointers
09.11.2024
medium3133. Minimum Array End
nth of increasing sequence with AND[..]=x manipulation
06.11.2024
medium3011. Find if Array Can Be Sorted
Can array be sorted by adjacent swap same-1-bits-nums
03.11.2024
easy796. Rotate String
Is string rotated goal?
30.10.2024
hard1671. Minimum Number of Removals to Make Mountain Array
Min removes to make a mountain programming search
29.10.2024
medium2684. Maximum Number of Moves in a Grid
Max increasing path from left to right in 2D matrix programming
28.10.2024
medium2501. Longest Square Streak in an Array
Longest quadratic subset
02.10.2024
easy1331. Rank Transform of an Array
Array values to their sorted set positions
01.10.2024
medium1497. Check If Array Pairs Are Divisible by k
Can all pairs sums be k-even?
30.09.2024
medium1381. Design a Stack With Increment Operation
Stack with range increment operation
28.09.2024
medium641. Design Circular Deque
Ring buffer
20.09.2024
hard214. Shortest Palindrome
Prepend to make the shortest palindrome hash
16.09.2024
medium539. Minimum Time Difference
Min difference in a list of times hh:mm
09.09.2024
medium2326. Spiral Matrix IV
LinkedList to spiral 2D matrix list
06.09.2024
medium3217. Delete Nodes From Linked List Present in Array
Remove nums from a Linked List list
02.09.2024
medium1894. Find the Student that Will Replace the Chalk
Position of a k sum in a cyclic array
01.09.2024
easy2022. Convert 1D Array Into 2D Array
D to 2D mxn array
31.08.2024
medium1514. Path with Maximum Probability
Max path in graph
17.08.2024
medium1937. Maximum Number of Points with Cost
Max top-down path sum with column diff in 2D matrix programming
16.08.2024
medium624. Maximum Distance in Arrays
Max diff between the arrays
14.08.2024
hard719. Find K-th Smallest Pair Distance
kth smallest pairs diff in an array search pointers
10.08.2024
medium959. Regions Cut By Slashes
Count islands divided by '\' and '/' in 2D matrix
09.08.2024
medium840. Magic Squares In Grid
Count 9x9 1..9 equal row col diag sum subgrids
08.08.2024
medium885. Spiral Matrix III
D spiraling order
05.08.2024
easy2053. Kth Distinct String in an Array
kth unique
03.08.2024
easy1460. Make Two Arrays Equal by Reversing Subarrays
Can arr transform to target by rotating subarrays?
02.08.2024
medium2134. Minimum Swaps to Group All 1's Together II
Min swaps to make a circular [01] array window
31.07.2024
medium1105. Filling Bookcase Shelves
Min total height to split [[w,h]] array by shelfWidth programming
25.07.2024
medium912. Sort an Array
Sort array using minimum memory
24.07.2024
medium2191. Sort the Jumbled Numbers
Sort array by digits mapping
23.07.2024
easy1636. Sort Array by Increasing Frequency
Sort by frequency or descending
22.07.2024
easy2418. Sort the People
Sort one array by another
21.07.2024
hard2392. Build a Matrix With Conditions
Build a matrix from a graph conditions
20.07.2024
medium1605. Find Valid Matrix Given Row and Column Sums
Matrix from rows and cols sums
19.07.2024
easy1380. Lucky Numbers in a Matrix
Min in rows and max in columns in a unique number matrix
6.07.2024
easy2582. Pass the Pillow
Loop position in increasing-decreasing array
3.07.2024
medium1509. Minimum Difference Between Largest and Smallest Value in Three Moves
Min difference after 3 changes in array window programming
2.07.2024
easy350. Intersection of Two Arrays II
Array intersection with duplicates
26.06.2024
medium1382. Balance a Binary Search Tree
Make a balanced Binary Search Tree
24.06.2024
medium995. Minimum Number of K Consecutive Bit Flips
Count k-range flips in binary array to make all 1 window
16.06.2024
hard330. Patching Array
Insertions to make subsets sums fill 1..n
14.06.2024
medium945. Minimum Increment to Make Array Unique
Min increments to make items unique
12.06.2024
medium75. Sort Colors
Sort 012 array
11.06.2024
easy1122. Relative Sort Array
Sort an array by the given order
10.06.2024
easy1051. Height Checker
Count unsorted elements in array
08.06.2024
medium523. Continuous Subarray Sum
Any subarray sum % k = 0
06.06.2024
medium846. Hand of Straights
Can array be split into consecutive groups
02.06.2024
easy344. Reverse String
Reverse an array
31.05.2024
medium260. Single Number III
Two not duplicated numbers from array manipulation
28.05.2024
medium1208. Get Equal Substrings Within Budget
Max substring sum(abs(s[..] - t[..])) < maxCost window
27.05.2024
easy1608. Special Array With X Elements Greater Than or Equal X
Count of more or equal nums[i] equal itself
15.05.2024
medium2812. Find the Safest Path in a Grid
Safest path in a grid with thieves
14.05.2024
medium1219. Path with Maximum Gold
Max one-way path in matrix
13.05.2024
medium861. Score After Flipping Matrix
Max binary-row sum after toggling rows and columns
12.05.2024
easy2373. Largest Local Values in a Matrix
Max pooling by 3x3 matrix
09.05.2024
medium3075. Maximize Happiness of Selected Children
Sum of k maximums decreasing each step
02.05.2024
easy2441. Largest Positive Integer That Exists With Its Negative
Max number that has its negative in array pointers
29.04.2024
medium2997. Minimum Number of Operations to Make Array XOR Equal to K
Bit diff between k and nums xor manipulation
26.04.2024
hard1289. Minimum Falling Path Sum II
Min non-direct path top down in a 2D matrix programming
20.04.2024
medium1992. Find All Groups of Farmland
Count 1-rectangles in 0-1 2D matrix
19.04.2024
medium200. Number of Islands
Count 1-islands in 0-1 a 2D matrix
18.04.2024
easy463. Island Perimeter
Perimeter of 1's islands in 01-matrix
13.04.2024
hard85. Maximal Rectangle
Max 1-only area in a 0-1 matrix
03.04.2024
medium79. Word Search
Does grid have a word path?
29.03.2024
medium2962. Count Subarrays Where Max Element Appears at Least K Times
Count subarrays with at least k array max in
26.03.2024
hard41. First Missing Positive
First number 1.. not presented in the array, O(1) space
25.03.2024
medium442. Find All Duplicates in an Array
All duplicate numbers of 1..n using O(1) memory
24.03.2024
medium287. Find the Duplicate Number
Duplicate single number in 1..n array, no extra memory
19.03.2024
medium621. Task Scheduler
Count CPU cycles if task can't run twice in n cycles
17.03.2024
medium57. Insert Interval
Insert interval into a sorted intervals array
16.03.2024
medium525. Contiguous Array
Max length of subarray sum(0) == sum(1)
15.03.2024
medium238. Product of Array Except Self
Array of suffix-prefix products
14.03.2024
medium930. Binary Subarrays With Sum
Count goal-sum subarrays in a 0-1 array
04.03.2024
medium948. Bag of Tokens
Max score converting power to token[i] and token[i] to score.
02.03.2024
easy977. Squares of a Sorted Array
Sorted squares.
22.02.2024
easy997. Find the Town Judge
Find who trusts nobody and everybody trusts him in [trust, trusted] array.
15.02.2024
medium2971. Find Polygon With the Largest Perimeter
The largest subset sum(a[..i]) > a[i + 1] where a is a subset of array.
14.02.2024
medium2149. Rearrange Array Elements by Sign
Rearrange array to positive-negative sequence.
13.02.2024
easy2108. Find First Palindromic String in the Array
Find a palindrome.
11.02.2024
medium1463. Cherry Pickup II
Maximum paths sum of two robots top-down in XY grid.
07.02.2024
medium451. Sort Characters By Frequency
Sort string by char's frequencies.
03.02.2024
medium1043. Partition Array for Maximum Sum
Max sum of partition array into chunks size of at most k filled with max value in chunk.
01.02.2024
medium2966. Divide Array Into Arrays With Max Difference
Split array into tripples with at most k difference.
31.01.2024
medium739. Daily Temperatures
Array of distances to the next largest.
27.01.2024
hard629. K Inverse Pairs Array
Number of arrays of 1..n with k reversed order pairs.
26.01.2024
medium576. Out of Boundary Paths
Number of paths from cell in grid to out of boundary.
23.01.2024
medium1239. Maximum Length of a Concatenated String with Unique Characters
Max length subsequence of strings array with unique chars.
22.01.2024
easy645. Set Mismatch
Return missing and duplicated number in 1..n array with one number replaced.
21.01.2024
medium198. House Robber
Max sum to rob non adjacent items in array.
20.01.2024
medium907. Sum of Subarray Minimums
Sum of minimums of all array ranges.
19.01.2024
medium931. Minimum Falling Path Sum
Min sum moving bottom center, left, right in 2D matrix.
17.01.2024
easy1207. Unique Number of Occurrences
Are array frequencies unique.
16.01.2024
medium380. Insert Delete GetRandom O(1)
Implement HashSet
7.01.2024
hard446. Arithmetic Slices II - Subsequence
Count of arithmetic subsequences.
4.01.2024
medium2870. Minimum Number of Operations to Make Array Empty
Minimum pairs or triples duplicate removal operations to empty array of numbers.
2.01.2024
medium2610. Convert an Array Into a 2D Array With Conditions
Convert numbers array into array of unique number-rows.
27.12.2023
medium1578. Minimum Time to Make Rope Colorful
Min sum of removed duplicates in array.
22.12.2023
easy1422. Maximum Score After Splitting a String
Max left zeros + right ones in 01-array
19.12.2023
easy661. Image Smoother
x3 average of each cell in 2D matrix
18.12.2023
easy1913. Maximum Product Difference Between Two Pairs
max second max - min second min
13.12.2023
easy1582. Special Positions in a Binary Matrix
#### Join me on Telegram
12.12.2023
easy1464. Maximum Product of Two Elements in an Array
#### Join me on Telegram
11.12.2023
easy1287. Element Appearing More Than 25% In Sorted Array
Most frequent element
10.12.2023
easy867. Transpose Matrix
Transpose 2D matrix
01.12.2023
easy1662. Check If Two String Arrays are Equivalent
Two dimensional array equals
25.11.2023
medium1685. Sum of Absolute Differences in a Sorted Array
Array to sum j(abs(arr[i] - arr[j])) for each i
24.11.2023
medium1561. Maximum Number of Coins You Can Get
Get sum of second maxes of triples from array
23.11.2023
medium1630. Arithmetic Subarrays
Query array ranges can form arithmetic sequence
22.11.2023
medium1424. Diagonal Traverse II
Diagonal 2D matrix order with prunes
21.11.2023
medium1814. Count Nice Pairs in an Array
Count pairs x-rev(x) == y-rev(y), where rev(123) = 321
19.11.2023
medium1887. Reduction Operations to Make the Array Elements Equal
Number of operations to decrease all elements to the next smallest
18.11.2023
medium1838. Frequency of the Most Frequent Element
Max count of equal numbers if increment arr[i] k times
17.11.2023
medium1877. Minimize Maximum Pair Sum in Array
Minimum possible max of array pairs sums
16.11.2023
medium1980. Find Unique Binary String
First absent number in a binary string array
10.11.2023
medium1743. Restore the Array From Adjacent Pairs
Restore an array from adjacent pairs
08.11.2023
medium2849. Determine if a Cell Is Reachable at a Given Time
Is path possible on grid sx, sy -> fx, fy
05.11.2023
medium1535. Find the Winner of an Array Game
Find maximum of the k nearest in array
31.10.2023
medium2433. Find The Original Array of Prefix Xor
Reverse xor operation
30.10.2023
easy1356. Sort Integers by The Number of 1 Bits
Sort an array comparing by bit count and value
26.10.2023
medium823. Binary Trees With Factors
Number of trees from arr where each k node has i and j leafs arr[k]=arr[j] arr[i]
12.10.2023
hard1095. Find in Mountain Array
Binary Search in a mountain
11.10.2023
hard2251. Number of Flowers in Full Bloom
Array of counts of segments in intersection
9.10.2023
medium34. Find First and Last Position of Element in Sorted Array
Binary Search range
7.10.2023
hard1420. Build Array Where You Can Find The Maximum Exactly K Comparisons
Count possible arrays of n 1..m values increasing k times
4.10.2023
easy706. Design HashMap
Design a HashMap
30.09.2023
medium456. 132 Pattern
132 pattern in array
29.09.2023
easy896. Monotonic Array
Is array monotonic
28.09.2023
easy905. Sort Array By Parity
Sort an array by even-odd
21.09.2023
hard4. Median of Two Sorted Arrays
Median in two concatenated sorted arrays
20.09.2023
medium1658. Minimum Operations to Reduce X to Zero
Min suffix-prefix to make an x
19.09.2023
medium287. Find the Duplicate Number
Found duplicate in array, each value is in 1..
11.09.2023
medium1282. Group the People Given the Group Size They Belong To
Groups from groups sizes array
9.09.2023
medium377. Combination Sum IV
Number of ways to sum up array nums to target
1.09.2023
easy338. Counting Bits
Array of bits count for numbers 0..n
30.08.2023
hard2366. Minimum Replacements to Sort the Array
Minimum number of number splits to make an array non-decreasing
29.08.2023
medium2483. Minimum Penalty for a Shop
First index of minimum penalty in array, penalty 'Y'-> 1, 'N' -> -1
27.08.2023
hard403. Frog Jump
Can jump an array when each jump is k-1..k+1 of the previous
17.08.2023
medium542. 01 Matrix
Distances to 0 in an 0-1 matrix
14.08.2023
medium215. Kth Largest Element in an Array
Kth largest in an array
13.08.2023
medium2369. Check if There is a Valid Partition For The Array
Is it possible to partition an array of 2 or 3 equal nums or 3 increasing nums.
12.08.2023
medium63. Unique Paths II
Number of right-down ways tl->br in a matrix with obstacles
11.08.2023
medium518. Coin Change II
Ways to make amount with array of coins
10.08.2023
medium81. Search in Rotated Sorted Array II
Binary Search in a rotated array with duplicates
08.08.2023
medium33. Search in Rotated Sorted Array
Binary Search in a shifted array
07.08.2023
medium74. Search a 2D Matrix
D Binary Search
28.07.2023
medium486. Predict the Winner
Optimally taking numbers from an array's ends can one player win another
25.07.2023
medium852. Peak Index in a Mountain Array
Mountain pattern index in the array in log time
21.07.2023
medium673. Number of Longest Increasing Subsequence
use an array cache, as Map gives TLE
19.07.2023
medium435. Non-overlapping Intervals
Minimum intervals to erase overlap
5.07.2023
medium1493. Longest Subarray of 1's After Deleting One Element
Largest 1..1 subarray after removing one item
4.07.2023
medium137. Single Number II
Let's use fold.
30.06.2023
hard1970. Last Day Where You Can Still Cross
Last day matrix connected top-bottom when flooded each day at cells[day]
29.06.2023
hard864. Shortest Path to Get All Keys
Min steps to collect all lowercase keys in matrix. # and uppercase locks are blockers.
28.06.2023
medium1514. Path with Maximum Probability
Max probability path from start to end in a probability edges graph
26.06.2023
medium2462. Total Cost to Hire K Workers
The sum of the smallest cost from suffix and prefix of a costs size of candidates in k iterations
24.06.2023
hard956. Tallest Billboard
Max sum of disjoint set in array
23.06.2023
medium1027. Longest Arithmetic Subsequence
Max arithmetic subsequence length in array
21.06.2023
hard2448. Minimum Cost to Make Array Equal
Min cost to make all arr[i] equal, where each change is cost[i]
20.06.2023
medium2090. K Radius Subarray Averages
Array containing sliding window of size 2k+1 average or -1
18.06.2023
hard2328. Number of Increasing Paths in a Grid
Count increasing paths in a matrix
17.06.2023
hard1187. Make Array Strictly Increasing
Minimum replacements to make arr1 increasing using any numbers arr2
16.06.2023
hard1569. Number of Ways to Reorder Array to Get Same BST
Count permutations of an array with identical Binary Search Tree
13.06.2023
medium2352. Equal Row and Column Pairs
Count of rowArray == colArray in an n x n matrix.
12.06.2023
easy228. Summary Ranges
Fold continues ranges in a sorted array 1 2 3 5 -> 1->3, 5
11.06.2023
medium1146. Snapshot Array
Implement an array where all elements can be saved into a `snapshot's.
10.06.2023
medium1802. Maximum Value at a Given Index in a Bounded Array
Max at index in an n sized array, where sum <= maxSum, nums[i] > 0 and maxDiff(i, i+1) < 2.
09.06.2023
easy744. Find Smallest Letter Greater Than Target
Lowest char greater than target.
08.06.2023
easy1351. Count Negative Numbers in a Sorted Matrix
Count negatives in a sorted by row and by column matrix.
01.06.2023
medium1091. Shortest Path in Binary Matrix
0 path length in a binary square matrix.
29.05.2023
easy1603. Design Parking System
Return if car of type 1, 2 or 3 can be added given sizes big, medium and small.
27.05.2023
hard1406. Stone Game III
Winner of “Alice”, “Bob” or “Tie” in game of taking 1, 2 or 3 stones by turn from stoneValue array.
21.05.2023
medium934. Shortest Bridge
Find the shortest path from one island of 1's to another.
14.05.2023
hard1799. Maximize Score After N Operations
Max indexed-gcd-pair sum from 2n array; [3,4,6,8] -> 11 (1gcd(3,6) + 2gcd(4,8))
12.05.2023
medium2140. Solving Questions With Brainpower
Let's implement a bottom-up solution.
11.05.2023
medium1035. Uncrossed Lines
use an array for the faster cache instead of HashMap
10.05.2023
medium59. Spiral Matrix II
to detect an empty cell, we can check it for == 0
9.05.2023
medium54. Spiral Matrix
do track the borders left, top, right, bottom
8.05.2023
easy1572. Matrix Diagonal Sum
avoid double counting of the center element
6.05.2023
medium1498. Number of Subsequences That Satisfy the Given Sum Condition
Precompute the 2-powers
2.05.2023
easy1822. Sign of the Product of an Array
There is an sign function in kotlin, but leetcode.com doesn't support it yet.
30.04.2023
hard1579. Remove Max Number of Edges to Keep Graph Fully Traversable
Use separate Union-Find objects for Alice and for Bob
28.04.2023
hard839. Similar String Groups
decrease the groups when the two groups are joined together
26.04.2023
easy258. Add Digits
It is just an array pointer loop shifted by 1.
25.04.2023
medium2336. Smallest Number in Infinite Set
Let's implement a sparse array.
23.04.2023
hard1416. Restore The Array
use Long to avoid overflow
21.04.2023
hard879. Profitable Schemes
Do DFS and cache result in an array.
15.04.2023
hard2218. Maximum Value of K Coins From Piles
We can cache the result by the keys of every pile to taken
09.04.2023
hard1857. Largest Color Value in a Directed Graph
use visited set to detect cycles
07.04.2023
medium1020. Number of Enclaves
We can use visited set, or modify the grid or use Union-Find.
06.04.2023
medium1254. Number of Closed Islands
DFS will solve the problem.
05.04.2023
medium2439. Minimize Maximum of Array
careful with integers overflows
04.04.2023
medium2405. Optimal Partition of String
use hashset, [26] array or simple 32-bit mask to store visited flags for character
03.04.2023
medium881. Boats to Save People
Sort an array and move two pointers lo and hi.
29.03.2023
hard1402. Reducing Dishes
The naive $$O(n^2)$$ solution will work. However, there is an optimal one if we simply go from the end.
27.03.2023
medium64. Minimum Path Sum
Use DFS + memo, careful with the ending condition.
25.03.2023
medium2316. Count Unreachable Pairs of Nodes in an Undirected Graph
use path compression for better root time complexity
24.03.2023
medium1466. Reorder Routes to Make All Paths Lead to the City Zero
We can use data structure or just use sign to encode the direction.
23.03.2023
medium1319. Number of Operations to Make Network Connected
for the better time complexity of the findRoot use path compression: uf[x] = n
22.03.2023
medium2492. Minimum Score of a Path Between Two Cities
Connect all roads and update minimums in the Union-Find data structure. Use simple arrays for both connections and minimums.
19.03.2023
medium211. Design Add and Search Words Data Structure
Let's try to write it in a Kotlin way, using as little words as possible.
18.03.2023
medium1472. Design Browser History
Just implement it.
12.03.2023
hard23. Merge k Sorted Lists
use dummy head
06.03.2023
easy1539. Kth Missing Positive Number
For more robust binary search code
02.03.2023
medium443. String Compression
Let's just do a naive toString for simplicity.
01.03.2023
medium912. Sort an Array
Let's just implement naive quicksort.
27.02.2023
medium427. Construct Quad Tree
use inclusive ranges to simplify the code
24.02.2023
hard1675. Minimize Deviation in Array
Use TreeSet to quickly access to the min and max elements.
21.02.2023
medium540. Single Element in a Sorted Array
Let's write a binary search. For more robust code, consider
15.02.2023
easy989. Add to Array-Form of Integer
use linked list to add to the front of the list in O(1)
12.02.2023
medium2477. Minimum Fuel Cost to Report to the Capital
Use DFS and data class for the result.
11.02.2023
medium1129. Shortest Path with Alternating Colors
Start with two simultaneous points, one for red and one for blue. Keep track of the color.
10.02.2023
medium1162. As Far from Land as Possible
Add all land cells into BFS, then just run it.
9.02.2023
hard2306. Naming a Company
Group and multiply. Don't forget to remove repeating elements in each two groups.
6.02.2023
easy1470. Shuffle the Array
For simplicity, use two pointers for the source, and one for the destination.
3.02.2023
medium6. Zigzag Conversion
Store simulation result in a [rowsNum][simulation indice] - matrix, then build the result.
28.01.2023
hard352. Data Stream as Disjoint Intervals
careful with merge
27.01.2023
hard472. Concatenated Words
first, scan all the words, and fill the Trie
26.01.2023
medium787. Cheapest Flights Within K Stops
by the problem definition, path length is k+1, not just k
24.01.2023
medium909. Snakes and Ladders
fun snakesAndLadders(board: Array
23.01.2023
easy997. Find the Town Judge
fun findJudge(n: Int, trust: Array
16.01.2023
medium57. Insert Interval
fun insert(intervals: Array
15.01.2023
hard2421. Number of Good Paths
fun numberOfGoodPaths(vals: IntArray, edges: Array
8.01.2023
hard149. Max Points on a Line
fun maxPoints(points: Array
5.01.2023
medium452. Minimum Number of Arrows to Burst Balloons
fun findMinArrowShots(points: Array
3.01.2023
easy944. Delete Columns to Make Sorted
fun minDeletionSize(strs: Array
1.01.2023
easy290. Word Pattern
fun wordPattern(pattern: String, s: String): Boolean {
31.12.2022
hard980. Unique Paths III
fun uniquePathsIII(grid: Array
30.12.2022
medium797. All Paths From Source to Target
fun allPathsSourceTarget(graph: Array> {
29.12.2022
medium1834. Single-Threaded CPU
fun getOrder(tasks: Array
27.12.2022
medium2279. Maximum Bags With Full Capacity of Rocks
fun maximumBags(capacity: IntArray, rocks: IntArray, additionalRocks: Int): Int {
24.12.2022
medium790. Domino and Tromino Tiling
fun numTilings(n: Int): Int {
22.12.2022
hard834. Sum of Distances in Tree
fun sumOfDistancesInTree(n: Int, edges: Array
21.12.2022
medium886. Possible Bipartition
fun possibleBipartition(n: Int, dislikes: Array
19.12.2022
easy1971. Find if Path Exists in Graph
fun validPath(n: Int, edges: Array
17.12.2022
medium150. Evaluate Reverse Polish Notation
fun evalRPN(tokens: Array
15.12.2022
medium1143. Longest Common Subsequence
fun longestCommonSubsequence(text1: String, text2: String): Int {
13.12.2022
medium931. Minimum Falling Path Sum
fun minFallingPathSum(matrix: Array
28.11.2022
medium2225. Find Players With Zero or One Losses
fun findWinners(matches: Array> {
27.11.2022
hard446. Arithmetic Slices II - Subsequence
fun numberOfArithmeticSlices(nums: IntArray): Int {
26.11.2022
hard1235. Maximum Profit in Job Scheduling
fun jobScheduling(startTime: IntArray, endTime: IntArray, profit: IntArray): Int {
24.11.2022
medium79. Word Search
fun exist(board: Array
23.11.2022
mediumValid Sudoku
fun isValidSudoku(board: Array
21.11.2022
mediumNearest Exit From Entrance In Maze
fun nearestExit(maze: Array
19.11.2022
hardErect The Fence
fun outerTrees(trees: Array
11.11.2022
easyRemove Duplicates From Sorted Array
Just do what is asked. Keep track of the pointer to the end of the "good" part.
7.11.2022
easyMaximum 69 Number
The simplest implementations would be converting to array of digits, replacing the first and converting back.
3.11.2022
mediumLongest Palindrome By Concatenating Two Letter Words
This is a counting task, can be solved linearly.
2.11.2022
mediumMinimum Genetic Mutation
make graph
1.11.2022
mediumWhere Will The Ball Fall
This is a geometry problem, but seeing the pattern might help. We can spot that each row is an action sequence: -1 -1 -1 shifts balls left, and 1 1 1 shifts balls to the right. Corners can be formed only with -1 1 sequence.
31.10.2022
easyToeplitz Matrix
just compare adjacent rows, they must have an equal elements except first and last