Memory Exceeded


Getting MLE using only two variables i and j,declared on two separate lines as well
Any help?


you also need to keep only required element in vector A, this means you will have to resize vector A.


But the task description says: “It does not matter what is left beyond the expected length.”. It should be modified to meet the requirements of the solution checker.


declare variable outside the for loop. do not use local variable…


Yeah agreed, But what @tanya-anand said works, so just suggest an edit saying that the solution error must meet the requirements of the question.


For C++ two pointers approach is giving MLE and the same logic in python is accepted. Try to submit in Python or some other language.

class Solution:
# @param A : list of integers
# @param B : integer
# @return an integer
def removeElement(self, A, B):
i = 0
j = 0
A[j] = A[i]
return j


If working in C++, make sure to call resize() before returning the result. This way your solution will pass the MLE.