(JAVA TA) 2 test cases failed

Two test cases are failed

hello @87adarsh.gupta
are u getting tle or wa?

Run Error , this one sir

test case 0 and test case 1 has failed sir

ur code is correct , on big test cases due to too many copy of array it is showing that error.

do it iteratively to avoid any copy.


public void moveZeroes(int[] nums) {
      int pos = 0;
      for(int i = 0; i < nums.length; i++){
      if(nums[i] != 0){
          nums[pos]= nums[i];
    for(;pos<nums.length; pos++){
       nums[pos] = 0;

Thanks sir , it passed all the test cases now