Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
next_greater_element_iii.go
next_greater_element_iii_test.go

README.md

< Previous                  Next >

556. Next Greater Element III (Medium)

Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.

Example 1:

Input: 12
Output: 21

 

Example 2:

Input: 21
Output: -1

 

Related Topics

[String]

Similar Questions

  1. Next Greater Element I (Easy)
  2. Next Greater Element II (Medium)
You can’t perform that action at this time.