Enumerate All Primes to N

Enumerate All Primes to N Problem Statement Write a program that takes an integer argument and returns all primes between 1 and that integer.  Problem Solving There is not much of any solving here as I already know an ancient and well known algorithm for this. It’s called the Sieve of Eratosthenes.  The idea is […]

Buy and Sell stock twice

Buy and Sell stock twice  Problem Statement  Given an array of stock prices on each day. Write a program that gives the maximum profit one can achieve by buying and selling a stock at most twice.  Problem Solving Immediately I started to think like I solved the previous one stock problem and thought of instead […]

Delete Duplicates From Sorted Array

Delete Duplicates From Sorted Array  Problem Statement Write a program that takes input as a sorted array and updates it so that all duplicates have been removed and the remaining elements have been shifted left to fill the empty indices. Problem Solving We need to update the array in place. Something gives me intuition about […]

Advancing through an Array

Advancing through an Array Problem Statement Write a program that takes an array of n integers, where A[i] denotes maximum we can advance from index i and return whether it is possible to reach the last index when started from the beginning  of the array.  Problem Solving  A simple solution to this problem would be […]

Multiply two arbitrary precision integers

Increment Arbitrary  precision number Problem Statement Write a program that takes two array B1 and B2 and return a new array with value B1 * B2 .  Problem Solving Straight forward I think this is again a duplicate of high school method simulation.  We need to break down this into manageable chunks or functions. First […]

Increment arbitrary precision number

Increment Arbitrary  precision number   Problem Statement Write a program that takes an array of digits encoding a decimal number D and updates the array to represent the number D+1.  Problem Solving Straight forward I can think of doing arithmetic as taught in school.  Add 1 to the last digit if the digit becomes more […]

Catch Me On Social !!