Feb 4 · 14 min read · Imagine you've just created an algorithm, and it works lightning-fast on your brand-new computer. You're thrilled with the results and can't wait to share your success, so you ask your friend to give it a try. However, when your friend runs the same ...
Join discussion
Feb 4 · 2 min read · QUESTION: Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2<sup>31</sup>, 2<sup>31</sup> - 1], then return 0. Assume the environment does not allow yo...
Join discussion
Jan 16 · 8 min read · A Problem Let’s start with a problem: I need to print first 10 natural numbers. There are several ways to solve this problem. But let's say we need to solve it using functions without using loops or calling a function more than once. The simplest way...
Join discussion
Jan 10 · 4 min read · Cyclic sort is an in-place and unstable sorting algorithm that is specifically designed to efficiently sort arrays where numbers are in a known range like from 1 to N. How does it work? Let’s take the following array as an example. We need to sort it...
Join discussion
Jan 7 · 4 min read · After solving the “find maximum number in an array” problem yesterday, I didn’t want to jump into something new immediately. I wanted to stay with the same concept and really let it sink in. So today, I picked the opposite version of the same problem...
Join discussion
Jan 6 · 6 min read · I'm starting my DSA journey, and honestly, I was looking for something simple enough that I wouldn't feel completely lost, but also something that would make me think a little. Finding the maximum number in an array seemed perfect—it's not scary, and...
Join discussion
Jan 5 · 4 min read · Counting Digits, Reversing Numbers, Palindromes, and Perfect Numbers Before arrays, before recursion, before graphs… most problems quietly begin with numbers. Digits. Place values. Division. Remainders. At first, these problems look simple. But once ...
Join discussion
Jan 2 · 3 min read · LeetCode 961: N-Repeated Element in Size 2N Array is usually solved with a simple Hash Set (O(N) space) or randomized checks. But recently, I challenged myself to solve it deterministically using O(1) space. The result? A modified version of Moore’s ...
Join discussion