## Compute Random Permutation

Compute Random Permutation Problem Statement  Design an Algorithm that creates a uniform permutation from (0 – n-1).  Given a random number generator that return a number (0 – n-1 ) with equal probability. Use as few call to it as possible.  Problem Solving Immediately I thought about the shuffle algorithm. However here we are provided […]

## Don’t just Learn, PLAY it…!!

Don’t just learn, PLAY it..!! After having set up the problem solving blog and observing it’s value in mere few weeks. I have now understood the benefits of regular practice, of doing and moving slowly rather than rushing and falling down miserably being. When I use to do that I use to fell hurt myself […]

## Sudoku Checker

Sudoku Checker Problem Statement Given  a vector<vector<int>> of size 9*9. Check whether it is a valid Sudoku or not.   Problem Solving  I thought of starting with Iterators, writing Iterators for row iterator a column iterator and square iterator.  This got me involved in a lot of Object Oriented Problem and how to implement == nicely.  […]

## Online Sampling

Online Sampling Problem Statement Write a program that takes a stream and reads value from it to maintain a random subset of k elements.  Problem Solving  Instantly I think about a function that takes in a stream First fetches k values to fill a vector of size k.  On further input decides whether to take […]

## Offline Sampling

Offline sampling  Problem Statement  Write a program that taken a vector on n integers and return a random sample of size k. All sample must be equally likely.  Problem Solving At first, I had trouble understanding what exactly is a sample,how do measure a probability of such a permutation.  After a while I thought that […]

## Next Permutation

Next Permutation Problem Statement Given a permutation M, return the next permutation. Problem Solving   In this problem, the first thing that clicks is to observe examples.  And after multiple attempts, I started seeing a pattern.  First of all we need to see if there is a next permutation. If the sequence is already in the […]

Catch Me On Social !!