My Collection of Solutions
  • I write up solutions to document my thought processes, and analyse my code/approach, for future reference.
  • I mostly post solutions to contest problems as they usually lack an editorial. Apart from that, I may still post solutions if I feel my approach differs greatly from the editorial's.
  • Leetcode's current way of viewing all my posted solutions through the profile page is subpar, with the solutions getting lost and difficult to search for. I am using this post to have a clearer, more organised view of my collection of solutions, for my own reference.
  • Markdown still has its limitations, such as unable to filter or sort... but this will do for now.

ContestProblemDifficultyApproachTimeSpaceBeats (T,S)
-214. Shortest PalindromeHard2-Pointers, BacktrackingO(𝑛²)O(𝑛)5.05%, 42.16%
-1545. Find Kth Bit in Nth Binary StringMediumLogarithmic ReductionO(log𝑘)O(1)100.00%, 72.92%
-2924. Find Champion IIMediumGreedy, Set filteringO(𝑛+𝑚)O(𝑛)74.17%, 80.31%
W-4063216. Lexicographically Smallest String After a SwapEasyGreedyO(𝑛)O(𝑛)86.34%, 87.79%
B-1353222. Find the Winning Player in Coin GameEasyMathO(1)O(1)73.16%, 8.49%
B-1353223. Minimum Length of String After OperationsMediumGreedyO(𝑛)O(𝑘)21.16%, 84.77%
B-1353224. Minimum Array Changes to Make Differences EqualMediumGreedyO(𝑛²)O(𝑛)29.90%, 23.02%
W-4073226. Number of Bit Changes to Make Two Integers EqualEasyBit ManipulationO(log𝑛)O(1)86.16%, 10.58%
W-4073227. Vowels Game in a StringMediumGame Theory, GreedyO(𝑛)O(1)78.26%, 51.99%
W-4073228. Maximum Number of Operations to Move Ones to the EndMediumGreedy, CountingO(𝑛)O(𝑛)15.04%, 7.20%
W-4073229. Minimum Operations to Make Array Equal to TargetHardGreedyO(𝑛)O(1)96.87%, 99.76%
W-4083232. Find if Digit Game Can Be WonEasyIterativeO(𝑛)O(1)5.18%, 42.08%
W-4083233. Find the Count of Numbers Which Are Not SpecialMediumPrecomputation of PrimesO(√𝑛)O(𝑛)80.00%, 5.49%
W-4083234. Count the Number of Substrings With Dominant OnesMediumGreedy, Brute ForceO(𝑛√𝑛)O(𝑛)9.38%, 27.34%
B-1363238. Find the Number of Winning PlayersEasyCountingO(𝑛𝑦+𝑚)O(𝑛×𝑦)10.00%, 31.25%
B-1363239. Minimum Number of Flips to Make Binary Grid Palindromic IMediumBrute ForceO(𝑚×𝑛)O(𝑚×𝑛)6.67%, 35.38%
B-1363240. Minimum Number of Flips to Make Binary Grid Palindromic IIMediumGreedyO(𝑚×𝑛)O(1)5.88%, 49.48%
W-4093242. Design Neighbor Sum ServiceEasyPadded GridO(𝑛²)O(𝑛²)5.66%, 82.75%
W-4093243. Shortest Distance After Road Addition Queries IMediumBFSO(𝑛𝑞+𝑞²)O(𝑛+𝑞)5.28%, 5.90%
W-4093244. Shortest Distance After Road Addition Queries IIHardGreedy, Removal from SetO(𝑛×𝑞)O(𝑛+𝑞)35.42%, 19.59%
W-4103248. Snake in MatrixEasySimple CommandsO(𝑛)O(1)10.30%, 46.61%
W-4103249. Count the Number of Good NodesMediumDFS, BFSO(𝑛)O(𝑛)5.77%, 18.15%
B-1373254. Find the Power of K-Size Subarrays IMediumSliding WindowO(𝑛)O(𝑛)15.26%, 56.34%
B-1373255. Find the Power of K-Size Subarrays IIMediumSliding WindowO(𝑛)O(𝑛)5.81%, 5.07%
W-4113258. Count Substrings That Satisfy K-Constraint IEasySliding WindowO(𝑛)O(1)28.64%, 99.09%
W-4123264. Final Array State After K Multiplication Operations IEasyGreedy, HeapO(𝑘log𝑛 + 𝑛log𝑛)O(𝑛)10.25%, 15.78%
W-4123265. Count Almost Equal Pairs IMediumBrute ForceO(𝑛²×𝑚)O(𝑚)35.77%, 96.50%
W-4123266. Final Array State After K Multiplication Operations IIHardGreedy, HeapO(𝑘log𝑛 + 𝑛log𝑛)O(𝑛)5.16%, 47.95%
W-4123267. Count Almost Equal Pairs IIHardPermutation Set Intersections, Sliding WindowO(𝑛²+𝑛𝑚⁴)O(𝑛𝑚⁴)28.00%, 5.33%
B-1383270. Find the Key of the NumbersEasyDigit ManipulationO(1)O(1)3.69%, 100.00%
W-4133274. Check if Two Chessboard Squares Have the Same ColorEasyParity CheckO(1)O(1)51.68%, 100.00%
W-4133275. K-th Nearest Obstacle QueriesMedium
W-4143280. Convert Date to BinaryEasy
W-4143281. Maximize Score of Numbers in RangesMedium
B-1393285. Find Indices of Stable MountainsEasy
B-1393286. Find a Safe Walk Through a GridMedium
W-4153289. The Two Sneaky Numbers of DigitvilleEasy
W-4163295. Report Spam MessageMedium
B-1403300. Minimum Element After Replacement With Digit SumEasy
B-1403301. Maximize the Total Height of Unique TowersMedium
B-1403302. Find the Lexicographically Smallest Valid SequenceMediumGreedy, Prefix-sum-like PrecomputationO(𝑛)O(𝑛)60.60%, 50.48%
B-1403303. Find the Occurrence of First Almost Equal SubstringHardZ-algorithm, 2-wayO(𝑛+𝑚)O(𝑛+𝑚)95.34%, 76.70%
W-4173304. Find the K-th Character in String Game IEasyBrute ForceO(𝑘)O(𝑘)48.45%, 56.78%
W-4173304. Find the K-th Character in String Game IEasyLogarithmic ReductionO(log𝑘)O(1)100.00%, 17.19%
W-4173305. Count of Substrings Containing Every Vowel and K Consonants IMediumBrute ForceO(𝑛²)O(1)33.81%, 7.44%
W-4173306. Count of Substrings Containing Every Vowel and K Consonants IIMediumSliding WindowO(𝑛)O(1)32.33%, 49.25%
W-4173307. Find the K-th Character in String Game IIHardBinary SearchO(log𝑘)O(log𝑘)21.09%, 26.46%
W-4203324. Find the Sequence of Strings Appeared on the ScreenMediumBrute ForceO(𝑛)O(𝑛)21.01%, 56.33%
W-4203325. Count Substrings With K-Frequency Characters IMediumSliding WindowO(𝑛)O(1)78.76%, 67.75%
W-4203326. Minimum Division Operations to Make Array Non DecreasingMediumGreedyO(𝑛√𝑚)O(1)34.74%, 48.36%
B-1423330. Find the Original Typed String IEasyCountingO(𝑛)O(1)66.10%, 55.62%
B-1423331. Find Subtree Sizes After ChangesMediumDFS, Brute ForceO(𝑛²)O(𝑛)5.01%, 5.08%
W-4213334. Find the Maximum Factor Score of ArrayMediumPrime FactorisationO(𝑛²)O(𝑛)5.83%, 59.60%
W-4223340. Check Balanced StringEasyIterativeO(𝑛)O(1)56.40%, 38.80%
W-4223341. Find Minimum Time to Reach Last Room IMediumDijkstraO(𝑛𝑚log(𝑛𝑚))O(𝑛×𝑚)15.16%, 7.18%
W-4223342. Find Minimum Time to Reach Last Room IIMediumDijkstraO(𝑛𝑚log(𝑛𝑚))O(𝑛×𝑚)8.26%, 13.72%
W-4243354. Make Array Elements Equal to ZeroEasyGreedy, Prefix SumZeroO(𝑛)O(1)79.51%, 73.70%
W-4243355. Zero Array Transformation IMediumGreedy, Prefix-sum-like PrecomputationO(𝑛+𝑞)O(𝑛)58.48%, 82.45%
W-4243356. Zero Array Transformation IIMediumGreedy, Prefix-sum-likeO(𝑛+𝑞)O(𝑛)97.37%, 41.05%
B-1443360. Stone Removal GameEasySimulationO(√𝑛)O(1)100.00%, 78.49%
B-1443361. Shift Distance Between Two StringsMediumPrecomputation GridO(𝑛)O(1)95.41%, 48.70%
W-4253364. Minimum Positive Sum Subarray EasyBrute ForceO(𝑛³)O(1)6.45%, 83.57%
W-4253365. Rearrange K Substrings to Form Target StringMediumGreedy with SortingO(𝑛log𝑘)O(𝑛)5.06%, 5.56%
W-4253366. Minimum Array SumMediumDynamic Programming (Iterative) with Greedy PreprocessingO(𝑛³)O(𝑛³)43.94%, 62.12%
B-1623633. Earliest Finish Time for Land and Water Rides IEasyGreedy linear passO(𝑛+𝑚)O(1)100.00%, 100.00%
B-1623634. Minimum Removals to Balance ArrayMedium2-Pointers Sliding WindowO(𝑛log𝑛)O(𝑛)63.46%, 7.04%
B-1623635. Earliest Finish Time for Land and Water Rides IIMediumGreedy linear passO(𝑛+𝑚)O(1)100.00%, 100.00%
W-4653668. Restore Finishing OrderEasySet lookupO(𝑛+𝑚)O(𝑚)38.41%, 78.94%
W-4653669. Balanced K-Factor DecompositionMediumPrime Factorisation, Combinatorial BFSO((log𝑛)!)O((log𝑛)!)68.08%, 16.68%
Comments (0)