Help Leetcode December Challenge

can anyone help me with this problem. I cannot start my answer.

You just need to check if the next_permuation of the given no. is greater than the current no. or not. If it is greater than the current no. you need to check it is under 32-bit size and if it is, just returns the answer else in all other conditions the answer is -1.

bro value of n is too big. i am not able to handle it can you plzz code it

int nextGreaterElement(int n) {
        string num = to_string(n);
        if (next_permutation(num.begin(), num.end())) {
            long res = stol(num);
            return res > INT_MAX ? -1 : res;
        } else {
            return -1;
        }
    }

thx bro