Problem 69: Generate Random Numbers According to Probability [TripleByte]
Logic, Problem Solving, Math
To learn more about the newsletter, check our detailed About Page + FAQs
To help me understand you better, please fill out this anonymous, 2-min survey. If you liked this post, make sure you hit the heart icon in this email.
Get a free Weekly Summary of the important updates in AI and Machine Learning here
Recommend this publication to Substack over here
Take the next step by subscribing here
To come up with the most optimal solution for today’s problem you’ll have to think outside the box.
But before we get to the problem yesterday, there are two things that you should do-
If you haven’t already, make sure you go and vote on the poll in yesterday’s post. It is important as I work on restructuring the newsletter.
Secondly, if you are looking for work, someone in my network is looking to hire a Machine Learning Engineer. The benefits involve fully remote work and an amazing no-limit vacation policy. If you’re interested in this role I’ve shared the job description in this LinkedIn post, along with the relevant contact information. I have been sharing job openings on my Instagram, so make sure you’re following me there if you’re looking for roles. Link at the end of this email/post.
Sponsored Segment
AlphaSignal is a free weekly Summary of the top developments in Machine Learning. They use AI to rank and send you the top developments in the field. Check them out. Reading them is a great way to stay in touch with the field and support my writing.
Sign up here- https://alphasignal.ai/?referrer=Devansh
If you are someone interested in sponsoring this newsletter, let me know.
Problem
This problem was asked by Triplebyte.
You are given n
numbers as well as n
probabilities that sum up to 1. Write a function to generate one of the numbers with its corresponding probability.
For example, given the numbers [1, 2, 3, 4]
and probabilities [0.1, 0.5, 0.2, 0.2]
, your function should return 1
10% of the time, 2
50% of the time, and 3 and 4 20% of the time.
You can generate random numbers between 0 and 1 uniformly.
I created Technology Made Simple using new techniques discovered through mentoring multiple people in top tech firms. The newsletter is designed to help you succeed, saving you from hours wasted on going through substandard resources, the Leetcode grind, or multi-hour-long lectures. I have a 100% satisfaction policy, so you can try it out at no risk to you. You can read the FAQs and find out more here. Use the button below to get 20% off for up to a whole year. Using this discount will drop the prices-
800 INR (10 USD) → 533 INR (8 USD) per Month
8000 INR (100 USD) → 6400INR (80 USD) per year
Before proceeding, if you have enjoyed this post so far, please make sure you like it (the little heart button in the email/post).
In the comments below, share what topic you want to focus on. I’d be interested in learning and will cover them. To learn more about the newsletter, check our detailed About Page + FAQs
If you liked this post, make sure you fill out this survey. It’s anonymous and will take 2 minutes of your time. It will help me understand you better, allowing for better content.
https://forms.gle/XfTXSjnC8W2wR9qT9
I see you living the dream.
Go kill all and Stay Woke,
Devansh <3
To make sure you get the most out of Technique Tuesdays, make sure you’re checking in the rest of the days as well. Leverage all the techniques I have discovered through my successful tutoring to easily succeed in your interviews and save your time and energy by joining the premium subscribers down below. Get a discount (for a whole year) using the button below
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 Machine Learning breakdowns: 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