Its giving index out of bound for 1 test case , but i dont know why :\

here is my code , it is only link of code , it wont run there , so please go to the leetcode link i gave , and try to submit it there

@Muskan-Gupta-598128740703036
Ok wait for few minute let me check your code

@Muskan-Gupta-598128740703036
Actually there is problem in remove() function. Consider this testcase
[“RandomizedSet”,“insert”,“remove”,“insert”,“getRandom”,“remove”,“insert”,“getRandom”]
[[],[1],[2],[2],[],[2],[2],[]]

Here where you tries to remove 2 (which is at the end of array), then your ind will be 1. Now when you remove 2 from array size of array decrease to 1. Now when your code reaches here int p=arr.get(ind); i.e arr.get(1) it will segmentation fault because arr[1] doesn’t exists now.

@Muskan-Gupta-598128740703036
Now what you can do is add this line after line 30 if(ind==arr.size()){ return true; }
Your code will get accepted. Mark this doubt as resolved if you have no more doubt regarding this question.

yeah , you are right , shit it was easy :\ , btw thanks