# Codenation Hiring test discussion

i came up with this solution for even paths but was late to submit. Also please someone share approach for first question i only passed 35/42 testcases for first.

3 Likes

Hey! I could also pass only 37/42 tests. Some unnoticable corner case maybe. How many did you solve overall?

I solved only the first one. I wasted too much time on second question and read the third one when it was too late. Probably third was the easiest one if my code uploaded above is correct.

1 Like

I solved first one with all testcases passed.

I solved the first one completely â€¦for every number you can calculate how many numbers have number of divisors greater than that number in the other range â€¦take the sum and after that if result for first is greater than second print A else if result is less print B else print DRAW

2 Likes

I calculated sum of divisors of all numbers in given range. And then used binary search to compare sum values between each pair of numbers in given two range.

1 Like

If we calculate winning probability, shouldnâ€™t we look for how many numbers have divisors less than the number of div of given numbers? This approach gave me 37/42. Can you explain your logic of taking greater numbersâ€¦

For the graph problem, I had similar approach complexity wise. Gave TLE on 10 test cases and 6 passedâ€¦

dfs is O(n+m) .this shouldnâ€™t give TLE.

Yes right. It should passâ€¦
But i did something very similar and got tle

upper bound of m is 10^5.

1 Like

But m was constrained to be min(1e5, n * (n + 1) / 2). I too had similar approach and same verdict

1 Like

You passed how many?

32 / 42 in 1st and 7 /16 in 3rd

1 Like

Hey can you please tell your exact approach. I did a dfs but i could pass only 8/16 test cases and rest were TLE. Can you share your code so that i can check where i went wrong.