TLE in Chef Impress of May Cookoff 2020

Hello there !!
I need your help in determining where and why my solution for CHFIMPRS is getting TLE ?

I have done all the things in the similar fashion as @rajarshi_basu explained in the except that i did not insert elements in the answer 2d array from the odd-even vector but i chose to insert them from the hash/frequency map.

So, will you please explain it to me :sweat_smile: ??

1 Like

Are you doing the same thing when m is odd/even?

1 Like

I have put up a condition that if number_of_elements_with_odd_frequency.size() > 0, then I am filling up the m/2 middle column separately … else there’s no need to fill matrix up in that loop and rest of the columns are filled symmetrically in the next for loop which will fill elements upto j < m/2

1 Like

Here a case for which your code is producing wrong output.

1
2 2
1 1
2 2
1 Like

Ohh, yes I think I will have to refine my thought process.
Thanks for the test case !!

1 Like