You have a stream of bytes from which you can read one byte at a time. You only have enough space to store one byte. After processing those bytes, you have to return a random byte. Note: The probability of picking any one of those bytes should be equal
AnswerBot
1y
Return a random byte from a stream of bytes with equal probability.
Create a variable to store the count of bytes read
Create a variable to store the current random byte
For each byte read, generate a ra...read more
Help your peers!
Add answer anonymously...
Top Mentor Graphics Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Mentor Graphics Software Developer
>
Mentor Graphics Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app