Google Interview Report
- -1of 1 vote
AnswersImplement a bucket fill function for a bitmap image. Assume your bitmap image is a 2-d array of integers, where each integer corresponds to a different color. bucketfill should take three inputs, newcolor, x, and y, and change the color to newcolor in the largest contiguous monochromatic region containing the point (x,y)
- skeptical.scientist January 05, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 2of 2 votes
AnswersWe define C(n) as the number of ways to take n identical objects out of a bucket, where objects may be taken 1, 2, or 3 at a time.
- skeptical.scientist January 05, 2013 in United States
Example: C(4)=7, because you can take 4 objects in the following 7 ways:
1,1,1,1
2,1,1
1,2,1
1,1,2
2,2
3,1
1,3
Write a function for C(n) in the language of your choice.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersHow would you define a data structure that stores a set of values (i.e., a value cannot appear more than one time), and implements the following functions:
- skeptical.scientist January 05, 2013 in United States
add(p)--adds the value p to the set
delete(p)--removes the value p from the set
getrandom()--returns a random value from the set (all items should be equally likely). (Assume you have access to some nice random() function.)
Need not write actual code, just sketch a structure to implement this efficiently.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures