Problem
This problem was asked by Facebook/Meta.
Given a function that generates perfectly random numbers between 1 and k (inclusive), where k is an input, write a function that shuffles a deck of cards represented as an array using only swaps.
It should run in O(N) time.
Hint: Make sure each one of the 52! permutations of the deck is equally likely.
Make sure you like this question on Substack. It really helps the newsletter grow. The solution to this problem will be shared tomorrow with the premium subscribers of the newsletter.
For a free trial of the newsletter, subscribe here. This will give you month-long access to the newsletter. This offer runs out May 13,2022; so act quickly!!!
Consider filling out this survey. This helps me understand you better and will allow me to improve the content: Link: https://forms.gle/XfTXSjnC8W2wR9qT9
Struggling to Prepare for Coding Interviews? Stuck on Leetcode Questions? Too busy to go through the endless resources available online? Subscribe to Coding Interviews Made Simple, a newsletter to help you succeed with your newsletter. Using techniques developed through my proven track record of mentoring people with their interviews, I will help you ace your FAANG/MAANG (and other Software Engineering) interviews.
It will let you get high-paying jobs at prestigious firms for less than 50 cents (30 Rupees) per day (only INR 800/month or roughly 10 USD/month).
Reach out to me on:
Instagram: https://www.instagram.com/iseethings404/
Message me on Twitter: https://twitter.com/Machine01776819
My LinkedIn: https://www.linkedin.com/in/devansh-devansh-516004168/
My content:
Read my articles: https://rb.gy/zn1aiu
My YouTube: https://rb.gy/88iwdd
Get a free stock on Robinhood. No risk to you, so not using the link is losing free money: https://join.robinhood.com/fnud75