Who else

who else
>never getting a job
here?

Attached: Screenshot_2019-07-17-15-58-06~01.png (1440x2560, 339K)

Other urls found in this thread:

adventofcode.com/2018/day/11
twitter.com/SFWRedditImages

Grit those teeth and try again desu

Brainlet. What was the task?

kek. not only is the solution wrong, it takes a shitload of time to reach that incorrect solution. what the fuck did you even do?

I honestly don’t know I just copied what some Indian youtuber said.

Then you deserve this.

>copying from pajeets
well there's your problem

i'm not sure this career path is for you, user.

What was the question?
What was the answer you gave them, that you copied from said Indian youtuber?

this guy is larping as me

Write API (a function or a collection of classes - design decisions are up to you as long as the code is clean, readable, maintainable, and reasonably memory- and CPU-efficient) to count number of coloured areas in an image. Then write an application that would use your API.

Input: a grey-scale image represented as a 2-dimensional array of unsigned bytes.

Output: array of 256 unsigned int numbers, each of them being a count of areas coloured with the corresponding shade of grey.


my solution was to iterate through each pixel and check for changes in colour and that wife be marked as an edge

Attached: shades-of-grey.png (640x640, 3K)

So a histogram ?

>and that wife be marked as an edge

Attached: 1447568699796.png (421x500, 258K)

In this case it's 3 black 2 grey and 1 white?

This is fascinating to me. Is this how interviews work in the codemonkey world? In my field, I'd answer a question like this with "Give me a day with stackoverflow and I'll figure it out, but most likely, I'll use some sklearn.image solution.", and everything else would be considered 'obscure'. What's the answer, some variant of watershed transformation?

sounds a lot like this adventofcode.com/2018/day/11
(My solution in C# takes 3.2sec)

You start at a random pixel and go in 4 directions from there, if those pixels are the same color, you do it again from them until no new pixels are the same color, marking which pixels have been checked already (an array of bools with same dimensions maybe) . That's your area 1. Then you go for a whatever pixel from those unchecked and repeat the process until every pixels are checked. Count areas along the way or mark them somehow and count at the end, whatever.
I've seen that question on some YouTube channel. Maybe TechLead?

why not
>start at pixel
>check all 4 directions
>if colors are the same then store the coordinates in a temporary array
>mark current pixel as visited and record color
>go to the next coordinate stored in the array
>check all 4 directions for matching color
>add coordinates to the array if matches
>mark current pixel as visited
>do until array is empty
>go to coordinates 0, 0 and look for the next unvisited coordinate
>repeat process
do not be tempted to use recursion
it may look clever but it's not used in the real world
please give me the job

My first thought is to pick a spot, recourse until you find every pixel in the shape, and then store that as an array. Then start at the next pixel not in the array and do it again

I would skip 0,0 and use 1,1. You can ignore all the outside border pixels as you will infer if they are part of the blob or not by checking the ones near them. Cuts off a huge chunk of your processing time.

Or to save even more time you could check 0,1 then check 0,3. You would have already checked 0,2. then on the next row you would check 1,0, then 1,2 and do a grid cutting your iteration in half

BFS across each color space probably. These interviewers want to see you think for yourself, not plagiarise peoples ideas blindly. Anyone can copy off SO

to clarify some bit:

This is most effective the smaller the sample size is. You would need to check corners on 1x1, 1x(H-1), (W-1)x1, (W-1)x(H-1)

0000000
0111110
0111110
0111110
0111110
0111110
0000000


As the sample size increases this becomes more effective, you will need to keep track of what colors the offset items are. This could be furthered improved by tracking which points have been logged and which haven't

0101010
1010101
0101010
1010101
0101010
1010101
0101010

fill(x, y) {
color = image[x][y];
frontier.push(coord{x, y});

while( !frontier.empty() ) {
coord = frontier.pop();

if ( 0

oops, frontier.push coords should be relative to the coord popped from the stack.

I'm reading this problem and it seems like everyone responding to you doesn't get it. If your input is:

[0, 2, 2] your output should be [1, 0, 2] right? Just scaled up to 255.

This is incredibly easy. Dictionary of 255 ints with a count for the key as a value. Go over each pixel, increment the value for the pixel as a key. To speed it up linearly you can just divide the image into n sub arrays, where n is the number of threads you can efficiently run and have each thread sum up their section and combine dictionaries at the end. For additional speed, sort the sub arrays and don't access the dictionary until you've found a new value.

You can use something similar to DFS i think.
1) Create an empty array of the same size as the image named visited
2) init at 0,0. set the tl colour as the current colour and mark it as visited
3) at current position, explore in 4 directions add unvisited of same colour to a search queue if they are unvisited
4) if any of the 4 directions contained a different colour, create a sub instance of the program with the init position at that pixel, add that to another queue (do not begin the new instance right now), do not add that pixel to the search queue.
5) continue bumping positions off the search queue (repeat from 3) and exploring there neighbours until the queue is empty. add 1 to a global list of coloured object
6) When the queue is empty, take the first position in the instance queue and check if it has been visited if not then bump it off and repeat above with that pixel as the starting pixel.

probably a better way to do it but thats how i would do it.

I can tell this is BFS just looking at it here and it makes lots of sense, but I would never be able to say in an interview. Id choke like a bitch and look retarded.

What defines "colored"? What conditions demarc an "area".

>mail.google.com
I would have trashed your application without reading it.

what the fuck im seeing?

Are those two top black areas considered the same, so the correct answer to get would be [2,2,2] or is it [3,2,2] if they are seperate?

ok, so either they want to have shit done or not.

the two black areas are indeed separate
so in the results array you would have the count of 3 at A[0] (0 is white), 2 for A[200] (gray) and 3 for A[255] (black)

whoops i mean 2 white, 2 gray, 3 black

A good developer can get shit done better, faster. Either way, 2 weeks plus google for interview questions is a dead giveaway you're either self taught or at most went through a code bootcamp. A pajeet can do your job for much cheaper.

What is the alternative to self study or bootcamp?

I had an extremely similar question to this in an interview
I got it right I believe but I legit forgot how to create a 2d array

shouldn't 255 be white and 0 black?

I love how everytime somebody post a question like this Jow Forumsentoomen appear in all their retardness

How can you be so full of yourself yet thinking taking a whole day on SO to solve a minor problem is normal ?

yeah i forgot computer colour works differently

Looks like you should have gone to school, you fucking baka.

Attached: 1562620977525.png (275x512, 38K)

Good first solution but that array of visited elements will get huge, need to use a different data structure like a Boolean array to store visited coordinates with a lookup speed better than O(N)

>do our work for us for free

I got this image to solve in 20mins. I don't feel very smart

Attached: satsiki??.png (483x487, 201K)

look up union-find

>mommy's frens are hedgie wedgies and bankie wankies
>good enough resume to call connections from above
>interview prep makes me want to cut myself
fuck I just want to drop out and be a neet

So flood fill to find each region is an acceptable solution? Should be linear time complexity right?

>had to stop it after 4 minutes
This kills the rustacean