Google's Online Challenge - Coding - Intern Questions approach help

FIrst problem was pretty standard, can be solved by dfs and maintaing the ancestors nodes, although i got TLE in one of the subtasks.

The second problem was very interesting though, the max or value will definitely be the ors of all the array elements, now to choose the smallest subset, i couldn`t think of any good approach other than the testing all subsets, later in gfg i saw the same problem but there it is solved just like the subset sum problem with complexity of n^2 which i think will not fit here due to the value beign of order 10^5. How did you guys solve it ??

2 Likes

Yeah I thought so too because they have their specifiec interview site too other than competitive sites.

1 Like

Oh god missed a great opportunity, could you share the procedure of applying, since I tried to Google but couldn’t find anything related to it and is there a way of getting notified about such events in the future. My college isn’t even aware about this, they want us to learn LaTeX and outdated syllabus FFS , feel like crying now : - (

1 Like

go to careers section of whatever company you like and there you can create account and get notified about opportunities.

I guess, integer distribution can be solved using dp and bitmasking.

Integer distribution can be solved by dp and Bit manipulation.
But I have dought in first question . I found a post whether the solution is greedy not passing all test cases …

First will not pass with greedy, with two state dp you will get tle, only solution afaik is using fft.

2 Likes

The question wasn’t solvable with the given constraints … it was a variation of subset cover which is NP hard … I geuss you should raise a ticket to google to notify them of the same as many of us have also done.

Just btw : Due to weak test cases … just checking subsets of size 1 , 2 , 3 gives AC … which is another fallacy at google’s end

9 Likes

Do you have any idea how many questions do we need to solve to get round 1 clear?

How to check for subset of size 3?

1 Like

Would you mind elaborating on the explanation there or pointing to the core concepts being used. Also where does binary lifting come into the picture in this?

1 Like

Can you share some ideas behind the second one, “Integer Distribution”??I think it’s like O(2^n*n) but could not formulate a dp

were can i get notification of such google or any other companies online coding challenges rounds??
plzz share the details with us :pray:

Be active on LinkedIn or forums like discuss.

I was able to get both question accepted
these were my questions
if someone solved both and is contacted for interview plz share with me here

also i would like to know about the difficulty of questions so please share how many you were able to solve

Thanks…

1 Like

The number of ways to divide n objects in n/2 pairs is = n!/(2^(n/2)(n/2)!)
which for n=20 comes out to be around 6
10^8;
Wont it give TLE.

Yeah that’s brute force, I knew and it would be around 6*10^8, so it should give TLE…

I didn’t give the test but these problems are very standard. The first one is O(T*N*100) using dfs+dp and second one can be solved by keeping which index is at the starting position.

For the smallest subset problem you could perform dp. You can use Kadane’s algorithm to solve the problem.

I got the 2nd problem… it was nice