Pattern
Implementation
A compact view of archive entries grouped by recurring technique.
170 entries
170 entries tagged as Implementation.
23.04.2026
medium2615. Sum of Distances
Sum of distances to each occurance
20.04.2026
easy2078. Two Furthest Houses With Different Colors
Max distance between different numbers
18.04.2026
easy3783. Mirror Distance of an Integer
Diff with reversal
16.04.2026
medium3488. Closest Equal Element Queries
Shortest distances to the same values
13.04.2026
easy1848. Minimum Distance to the Target Element
Distance to target from start
11.04.2026
medium3741. Minimum Distance Between Three Equal Elements II
Min sum of distances between i,j,k of the same values
10.04.2026
easy3740. Minimum Distance Between Three Equal Elements I
Min sum of distances between i,j,k of the same values
30.03.2026
medium2840. Check if Strings Can be Made Equal With Operations II
Strings equal at odd-even positions
29.03.2026
easy2839. Check if Strings Can be Made Equal With Operations I
Match a and b at (0|2,1|3) positions
21.03.2026
medium3643. Flip Square Submatrix Vertically
Reverse submatrix k by k
15.03.2026
hard1622. Fancy Sequence
Design: add number, mulriply all, add all
11.03.2026
easy1009. Complement of Base 10 Integer
Invert binary
09.03.2026
medium3129. Find All Possible Stable Binary Arrays I
Count 01-arrays with z zeros, o ones, at most l repeat
15.02.2026
easy67. Add Binary
Binary strings sum
10.02.2026
medium3719. Longest Balanced Subarray I
Longes even=odd subarray
18.01.2026
medium1895. Largest Magic Square
Max magic square
17.01.2026
medium3047. Find the Largest Area of Square Inside Two Rectangles
Max square in intersection
16.01.2026
medium2975. Maximum Square Area by Removing Fences From a Field
Max square after remove vertical or horizontal bars
14.01.2026
hard3454. Separate Squares II
Min y to equal split areas exclude intersections sweep
12.01.2026
easy1266. Minimum Time Visiting All Points
Euclid travel distance
26.12.2025
medium2483. Minimum Penalty for a Shop
Min close time by customers max volune
20.12.2025
easy944. Delete Columns to Make Sorted
Count unsorted columns
15.12.2025
medium2110. Number of Smooth Descent Periods of a Stock
Decreasing subarrays
14.12.2025
hard2147. Number of Ways to Divide a Long Corridor
Ways to split pairs of S
13.12.2025
easy3606. Coupon Code Validator
Filter a,b,c accroding to rules
10.12.2025
medium3577. Count the Number of Computer Unlocking Permutations
Permutations to unlock all c[j] right and bigger than c[i]
08.12.2025
easy1925. Count Square Sum Triples
Count a^2+b^2=c^2 in 1..n range
05.12.2025
easy3432. Count Partitions with Even Sum Difference
Count Left sum - Right sum % 2
02.12.2025
medium3623. Count Number of Trapezoids I
Trapezoids count
01.12.2025
hard2141. Maximum Running Time of N Computers
Max time to run n computers with batteries
25.11.2025
medium1015. Smallest Integer Divisible by K
Smallest number 11..1 % k
24.11.2025
easy1018. Binary Prefix Divisible By 5
Prefixes divisible by 5
23.10.2025
medium1262. Greatest Sum Divisible by Three
Max sum that %3
22.11.2025
easy3190. Find Minimum Operations to Make All Elements Divisible by Three
Min steps inc/dec to make %3
21.11.2025
medium1930. Unique Length-3 Palindromic Subsequences
palindroms subsequences
17.11.2025
easy1437. Check If All 1's Are at Least Length K Places Away
All ones k-distant
16.11.2025
medium1513. Number of Substrings With Only 1s
Substrings of ones
13.11.2025
medium3228. Maximum Number of Operations to Move Ones to the End
Max steps to move all ones to the right
27.10.2025
medium2125. Number of Laser Beams in a Bank
Count multiplications between rows
26.10.2025
medium2043. Simple Bank System
Design a bank
24.10.2025
medium2048. Next Greater Numerically Balanced Number
First bigger number freq[digit]=digit
15.10.2025
medium3350. Adjacent Increasing Subarrays Detection II
Max k of adjucent increasing k-windows
14.10.2025
medium3349. Adjacent Increasing Subarrays Detection I
Any increasing consequent windows size k
27.09.2025
easy812. Largest Triangle Area
Max area triangle
23.09.2025
medium165. Compare Version Numbers
Compare versions x.x.x.x
22.09.2025
easy3005. Count Elements With Maximum Frequency
Count max-freq elements
20.09.2025
medium3508. Implement Router
Design Router: addPacket, forwardPacket, getCount(dst, ts start..end)
18.09.2025
medium3408. Design Task Manager
Design Scheduler: add, edit, remove, execute by priority
17.09.2025
medium2353. Design a Food Rating System
Food rating system: change rating, peek highest by type
15.09.2025
easy1935. Maximum Number of Words You Can Type
Count words with all letters
14.09.2025
medium966. Vowel Spellchecker
Spellcheck with priority: original, case, vowels
07.09.2025
easy1304. Find N Unique Integers Sum up to Zero
Any n uniq numbers with sum of 0
05.09.2025
medium2749. Minimum Operations to Make the Integer Zero
Min ops to subtract n2+2^(0..60) from n1 and make n1=0
04.09.2025
easy3516. Find Closest Person
Compare two distances
30.08.2025
medium36. Valid Sudoku
Validate sudoku has no duplicates
26.08.2025
medium3000. Maximum Area of Longest Diagonal Rectangle
Max area of max diagonal rectangles
23.08.2025
hard3197. Find the Minimum Area to Cover All Ones II
Min sum all-1 areas of 3-split
22.08.2025
medium3195. Find the Minimum Area to Cover All Ones I
Min all-1 rectangle
19.08.2025
medium2348. Number of Zero-Filled Subarrays
Count 0-subarrays
7.08.2025
hard3363. Find the Maximum Number of Fruits Collected
Max 3 paths from corners to bottom end
4.08.2025
medium904. Fruit Into Baskets
Max consequent two-types range
1.08.2025
easy118. Pascal's Triangle
Pascal's Triangle
30.07.2025
medium2419. Longest Subarray With Maximum Bitwise AND
Longest max OR subarray
25.07.2025
easy3487. Maximum Unique Subarray Sum After Deletion
Max non-empty uniq subsequence sum
26.06.2025
medium2311. Longest Binary Subsequence Less Than or Equal to K
Longest binary subsequence less than K
20.06.2025
medium3443. Maximum Manhattan Distance After K Changes
Max distance after k flips
16.06.2025
easy2016. Maximum Difference Between Increasing Elements
Max increasing pair diff
14.06.2025
easy2566. Maximum Difference by Remapping a Digit
Max - min, replacing any digit
10.06.2025
easy3442. Maximum Difference Between Even and Odd Frequency I
Max odd - min even frequency
24.05.2025
easy2942. Find Words Containing Character
Indices with x
19.05.2025
easy3024. Type of Triangle
Triangle type by lengths
11.05.2025
easy1550. Three Consecutive Odds
odds
04.05.2025
easy1128. Number of Equivalent Domino Pairs
Dominoes pairs
03.05.2025
medium1007. Minimum Domino Rotations For Equal Row
Min swaps to make a top or bottom row
30.04.2025
easy1295. Find Numbers with Even Number of Digits
Even length numbers
27.04.2025
easy3392. Count Subarrays of Length Three With a Condition
subarrays 2a + 2c == b
23.04.2025
easy1399. Count Largest Group
Count of max groups by digits sum 1..n
22.04.2025
hard2338. Count the Number of Ideal Arrays
Arrays a[i] % a[i - 1] == 0, i..n, a[i]..max
11.04.2025
easy2843. Count Symmetric Integers
Numbers with equal half' sums
03.04.2025
medium2874. Maximum Value of an Ordered Triplet II
Max (a[i] - a[j]) a[k]
27.02.2025
medium873. Length of Longest Fibonacci Subsequence
Longest sequence a, b, a + b programming
12.02.2025
medium2342. Max Sum of a Pair With Equal Sum of Digits
Max pairs sum with equal digits sum
08.02.2025
medium2349. Design a Number Container System
Smallest running index of number in map
04.02.2025
easy1800. Maximum Ascending Subarray Sum
Max increasing subarray sum
09.01.2025
easy2185. Counting Words With a Given Prefix
Count words with prefix
04.01.2025
medium1930. Unique Length-3 Palindromic Subsequences
Count palindromes of length 3
31.12.2024
medium983. Minimum Cost For Tickets
Min sum buying 1,7,30-days tickets to travel all days programming
02.11.2024
easy2490. Circular Sentence
Are words circular?
12.09.2024
easy1684. Count the Number of Consistent Strings
Count words with allowed characters
07.08.2024
hard273. Integer to English Words
Integer to English words
29.07.2024
medium1395. Count Number of Teams
Count increasing or decreasing (i, j, k)
1.07.2024
easy1550. Three Consecutive Odds
Has window of 3 odds?
13.06.2024
easy2037. Minimum Number of Moves to Seat Everyone
Sum of diffs of sorted students and seats
05.06.2024
easy1002. Find Common Characters
Common letters in words
26.05.2024
hard552. Student Attendance Record II
N times: A -> LP, L -> AP, P -> AL, at most one A, no LLL programming
31.03.2024
hard2444. Count Subarrays With Fixed Bounds
Count subarrays of range minK..maxK
20.03.2024
medium1669. Merge In Between Linked Lists
Replace a segment in a LinkedList
08.03.2024
easy3005. Count Elements With Maximum Frequency
Count of max-freq nums
18.02.2024
hard2402. Meeting Rooms III
Most frequent room of 0..
12.02.2024
easy169. Majority Element
Element with frequency > nums.len / 2.
06.02.2024
medium49. Group Anagrams
Group words by chars in them.
02.02.2024
medium1291. Sequential Digits
Numbers with sequential digits in low..high range.
28.01.2024
hard1074. Number of Submatrices That Sum to Target
Count submatrix target sums.
15.01.2024
medium2225. Find Players With Zero or One Losses
[sorted winners list, sorted single lose list]
14.01.2024
medium1657. Determine if Two Strings Are Close
Are strings convertible by swapping existing chars positions or frequencies.
9.01.2024
easy872. Leaf-Similar Trees
Are leafs sequences equal for two trees.
3.01.2024
medium2125. Number of Laser Beams in a Bank
Beams count between consequent non-empty row's 1s.
30.12.2023
easy1897. Redistribute Characters to Make All Strings Equal
Is it possible to split all the words[] characters into words.size groups.
26.12.2023
medium1155. Number of Dice Rolls With Target Sum
Ways to throw once n dices with k faces to make target sum.
20.12.2023
easy2706. Buy Two Chocolates
Money change after two chocolates bought
17.12.2023
medium2353. Design a Food Rating System
Given foods, cuisines and ratings implement efficient methods changeRating(food, newRating) and highestRated(cuisine)
16.12.2023
easy242. Valid Anagram
#### Join me on Telegram
15.12.2023
easy1436. Destination City
#### Join me on Telegram
14.12.2023
easy2482. Difference Between Ones and Zeros in Row and Column
diff[i][j] = onesRowi + onesColj - zerosRowi - zerosColj
05.12.2023
easy1688. Count of Matches in Tournament
Count of odd-even matches according to the rules x/2 or 1+(x-1)/2.
03.12.2023
easy1266. Minimum Time Visiting All Points
Path coordinates distance in XY plane
02.12.2023
easy1160. Find Words That Can Be Formed by Characters
Sum of words lengths constructed by chairs
27.11.2023
medium935. Knight Dialer
Count of dialer n-length numbers formed by pressing in a chess Knight's moves
20.11.2023
medium2391. Minimum Amount of Time to Collect Garbage
Time to pick 3-typed garbage[] by 3 trucks traveling to the right travel[] time
09.11.2023
medium1759. Count Number of Homogenous Substrings
Count of substrings of same chars
07.11.2023
medium1921. Eliminate Maximum Number of Monsters
Count possible 1-minute kills in a game of dist[] targets falling with speed[]
04.11.2023
medium1503. Last Moment Before All Ants Fall Out of a Plank
Max time ants on a line when goint left and right
16.10.2023
easy119. Pascal's Triangle II
Pascal's Triangle
14.10.2023
hard2742. Painting the Walls
Min cost to complete all tasks using one paid cost[] & time[] and one free 0 & 1 workers
8.10.2023
hard1458. Max Dot Product of Two Subsequences
Max product of two subsequences
6.10.2023
medium343. Integer Break
Max multiplication of the number split
3.10.2023
easy1512. Number of Good Pairs
Count equal pairs
2.10.2023
medium2038. Remove Colored Pieces if Both Neighbors are the Same Color
Is A wins in middle-removing AAA or BBB game
25.09.2023
easy389. Find the Difference
Strings difference by a single char
24.09.2023
medium799. Champagne Tower
Positional flow value in a Pascal's Triangle
16.09.2023
medium1631. Path With Minimum Effort
Minimum absolute difference in path top-left to right-bottom
10.09.2023
hard1359. Count All Valid Pickup and Delivery Options
Count permutations of the n pickup -> delivery orders
3.09.2023
medium62. Unique Paths
Unique paths count, moving right-down from top-left to bottom-right
18.08.2023
medium1615. Maximal Network Rank
Max edges count for each pair of nodes
06.08.2023
hard920. Number of Music Playlists
Playlists number playing n songs goal times, repeating each once in a k times
31.07.2023
medium712. Minimum ASCII Delete Sum for Two Strings
Minimum removed chars sum to make strings equal
16.07.2023
hard1125. Smallest Sufficient Team
Smallest team from people with skills, having all required skills
12.07.2023
medium802. Find Eventual Safe States
List of nodes not in cycles
25.06.2023
hard1575. Count All Possible Routes
Count paths from start to finish using |locations[i]-locations[j] of the fuel
22.06.2023
medium714. Best Time to Buy and Sell Stock with Transaction Fee
Max profit from buying stocks and selling them with fee for prices[day]
19.06.2023
easy1732. Find the Highest Altitude
Max running sum
05.06.2023
easy1232. Check If It Is a Straight Line
Are all the x,y points in a line?
26.05.2023
medium1140. Stone Game II
While Alice and Bob optimally take 1..2 m numbers from piles find maximum for Alice.
25.05.2023
medium837. New 21 Game
Probability sum of random numbers 1..maxPts sum be < n after it overflow k.
23.05.2023
medium703. Kth Largest Element in a Stream
Kth largest
16.05.2023
medium24. Swap Nodes in Pairs
Swap adjacent ListNodes a-b-c-d -> b-a-d-c.
7.05.2023
hard1964. Find the Longest Valid Obstacle Course at Each Position
google what is the solution of LIS
3.05.2023
easy2215. Find the Difference of Two Arrays
One way is to use two Sets and just filter them.
1.05.2023
easy1491. Average Salary Excluding the Minimum and Maximum Salary
We can do .fold and iterate only once, but sum, max and min operators are less verbose.
17.04.2023
easy1431. Kids With the Greatest Number of Candies
Let's write the code
20.03.2023
easy605. Can Place Flowers
careful with corner cases
05.03.2023
hard1345. Jump Game IV
This problem gives TLE until we do one trick
25.02.2023
easy121. Best Time to Buy and Sell Stock
we can just use current value as a max candidate instead of managing the max variable.
7.02.2023
medium904. Fruit Into Baskets
careful with corner cases
29.01.2023
hard460. LFU Cache
one thing to note, on each increaseFreq operation we are retrieving a random item from TreeMap, that increases time to O(log(F)), where F is a unique set of frequencies.
25.01.2023
medium2359. Find Closest Node to Given Two Nodes
fun closestMeetingNode(edges: IntArray, node1: Int, node2: Int): Int {
19.01.2023
medium974. Subarray Sums Divisible by K
fun subarraysDivByK(nums: IntArray, k: Int): Int {
18.01.2023
medium918. Maximum Sum Circular Subarray
fun maxSubarraySumCircular(nums: IntArray): Int {
7.01.2023
medium134. Gas Station
fun canCompleteCircuit(gas: IntArray, cost: IntArray): Int {
4.01.2023
medium2244. Minimum Rounds to Complete All Tasks
fun minimumRounds(tasks: IntArray): Int {
28.12.2022
medium1962. Remove Stones to Minimize the Total
fun minStoneSum(piles: IntArray, k: Int): Int {
26.12.2022
medium55. Jump Game
fun canJump(nums: IntArray): Boolean {
20.12.2022
medium841. Keys and Rooms
fun canVisitAllRooms(rooms: List>): Boolean {
12.12.2022
easy70. Climbing Stairs
val cache = mutableMapOf
4.12.2022
medium2256. Minimum Average Difference
fun minimumAverageDifference(nums: IntArray): Int {
29.11.2022
medium380. Insert Delete GetRandom O(1)
class RandomizedSet() {
25.11.2022
medium907. Sum of Subarray Minimums
data class V(val v: Int, val count: Int)
16.11.2022
easyGuess Number Higher Or Lower
override fun guessNumber(n:Int):Int {
14.11.2022
mediumMost Stones Removed With Same Row Or Column
From observing the problem, we can see, that the task is in fact is to find an isolated islands
12.11.2022
hardFind Median From Data Stream
To find the median we can maintain two heaps: smaller and larger. One decreasing and one increasing.