Exist Or NOt . . .

bhaiya , ye dekhna isse better bhi kuch kar sakte hai kya?

hello @CODER_JATIN

thoda improve kar sakte hai, map use karne ki bajaye tum array use kar sakte ho. jise phir O(1) me answer kar sakte ho,jabki map me worst case me O(N) chala jaata hai

array use karke to bhaiya o(n) ni hoga worst case mai for each checking?

nahi , jaise tum map ko use kar rahe ho ,waise hi array ko use karo.

jaise ki map[5]=true kar rahe ho,
wise hi tum array[5]=1 kar do ,initilally sab me 0 rakho
isse hamesha O(1) rahega per query.

okay okay bhaiya , samajh gya :slight_smile:

thank you :slight_smile: , , , ,

try karna ek baar , abhi usme ek dikkat aayegi tumhe

abhi karta hu bhaiya ,

https://ide.codingblocks.com/s/444053 , dekho bhaiya , sample output hi sahi aari bs

tumne ek chiz ka to dhyan hi nahi rakha ki element negative bhi ho sakgte hai haina?
socho thoda kaise handle karoge

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.