Search
⌘K

Leetcode 556. Next Greater Element III

Find the smallest integer greater than n that uses exactly the same digits (i.e., the next lexicographic permutation of n's digits); return -1 if no such permutation exists or if the result exceeds the 32-bit signed integer limit (2^31−1).

Asked at:

Meta

Goldman Sachs


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid July, 2025

Meta

Mid-level

Next Greater Element III

Late June, 2025

Goldman Sachs

Mid-level

Late January, 2025

Meta

Senior

Given an integer, find the next smallest integer that can be formed using the same digits.

Comments

Your account is free and you can post anonymously if you choose.