We have been asked to return the integer that has been repeated. There could only be one number that has been repeated and only once. In an array of length n+1, the elements are in the range [1, n]. They have specified that the original array shoul...
We have been asked to return an integer array such that it has elements in respective indices of a given integer array which are products of all the other elements except itself. I.e., the array to be returned (say) output has elements such that, out...
Problem description A naive method find all the numbers that has a value of key, save their positions in a list loop through the list as j find index i that is not k steps further than j if there is at least 1 index i that fits the requiremnt, add...
Problem description Algorithm walkthrough Use helper function 1 to change a number into base k Use helper function 2 to check if a number is a palindrome In the main function, find n numbers that are both palindromes in base 10 and base k Naive app...
Problem description Algorithm walkthrough Input and output The divideString method takes three parameters: s: The input string to be divided k: The size of each group fill: The character used to pad the last group if needed And we need to return the...
Problem Description I assume you have read the original problem description in the link above, so I will share some key points about a common mistake in the problem, which is using a greedy approach. A common mistake: greedily delete from the most co...
Problem Description Thinking process Let's read the problem description first. It mentioned that we have a list of directions in sequence, given at most k times to change direction at any step. How far can you go from the base point in Manhattan dist...
First blog for my interview Prep. I’m doing this to keep me consistent, motivated and accountable.
Difficulty: EasyLeetCode Problem #13 Whether you're prepping for coding interviews or brushing up your algorithm skills, converting Roman numerals to integers is a classic problem worth mastering. Let's walk through the logic, break it down step-by-s...
❓ The Problem You’re given an array of coin denominations (e.g. [1, 2, 5])and a target amount (e.g. 11).Return the minimum number of coins needed to make up that amount.If it's not possible, return -1. 🎯 What You’re Really Being Asked Find the s...