Any other method to solve this?

Any other method to solve this?

You can refer this

class Solution {
public:
    vector<int> sumZero(int n) {
      int temp=n/2;
      vector<int>result;
      for(int i=-1*temp;i<0;i++) result.push_back(i);
      if(n&1) result.push_back(0);
      for(int i=1;i<=temp;i++) result.push_back(i);
      return result;
    }
};

It is somewhat similar to your approach.

Sir Is logic same
Pehle -2 -1 0 insert krdo fir 0 1 2??

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.