Year

2023 archive

A year-sized slice of the daily archive, ordered newest first.

363 entries

363 entries from 2023.

14.10.2023

hard

2742. Painting the Walls

Min cost to complete all tasks using one paid cost[] & time[] and one free 0 & 1 workers

dp_memo depth-first-search memoization_with_state_compression bit-shifting_for_state_storage scheduling_and_cost_minimization implicit_state_space

25.05.2023

medium

837. New 21 Game

Probability sum of random numbers 1..maxPts sum be < n after it overflow k.

cache depth-first-search memoization_with_recurrence algebraic_manipulation boundary_condition_analysis probability

10.05.2023

medium

59. Spiral Matrix II

to detect an empty cell, we can check it for == 0

Array is used to represent the matrix and store results. Iterative traversal of the matrix is used to fill the spiral pattern. Simulating a robot moving in a spiral pattern to fill the matrix. Checking boundaries and visited status before moving to the next cell. The problem involves generating a spiral matrix. Using 2D arrays to represent the matrix.

29.01.2023

hard

460. 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.

TreeMap LinkedHashSet Frequency Bucketing Ordered Access Lists Cache Data Structures