why am i getting WA and TLE with this solution?
Exist or not WA and TLE
Hi @Prajawal-Pandey-2140320206067139, since the testcases can be very large, it is preferable that you insert the input values in the hashmap by using insert function and then check by using count function instead of doing m[a[i]] as false, otherwise for very large inputs, you will get TLE.
If doubt still persists, reply to this thread, else mark it as resolved.
sorry i didnt understand u…
im just providing false to my value of key…i can provide true instead it doesnt matter… im not using it anywhere…
and im not only getting tle…im getting wrong answers too for 2 test cases
Alright, I got your point. You don’t need to create an array. Read one number at a time and insert it in map directly without storing it in array. This will save your space.
i dont need to save space…i am getting wa and tle
BTW i tried what u said…still getting WA, TLE and WA
Please share your updated code.
@Prajawal-Pandey-2140320206067139, you’re creating a global hashmap for all testcases. You need to create a new map for every testcase.
still getting TLE for 2nd testcase
I’m not sure why that is happening. I’ve done the same and my code works: https://ide.codingblocks.com/s/94340. I’ll try to figure out what’s wrong and let you know.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.