Pair of roses - Wrong Answer

Working on ide with all test cases . . . but showing the wrong answer on the contest.
question -
Answer -
Please let me know where I am wrong.

I have made the required changes and it passed the test case.
Note: this problem can be solved in O(NlogN) approach and you used O(N^2) approach.


Bro can u plzz tell me how to find time complexity like u found its O(N^2) for my problem.
I want some good resources to learn to find the time complexity .
Till now i have been watching codeschool and Ravindarbabu tutorials on youtube for time complexity . . Do u have any more on your list which are best or any book or anything, then Plzz recommend me.

Your code has 2 loops of size N nested with each other, thats why i said it is O(N^2).
You can refer to Cormen (Best book for data structures and algos) for more help.

you can refer to this as well…

1 Like

Thanks for your Advice . . also can u refer some reference material for c++ any best book or pdf related document of stl libraries with c++ , so that we can revise that material while we are in college or in bus or any free time. It would be gr8 help if u would refer a pdf orr book that has the detailed knowledge.

You can refer cormen or schaum series. Hackerearth is good site for learning topics. And codingblocks assignments are amazing stuff for practice.

Abhishek can you tell me what is wrong with my code it passes the test cases