All Problems

Maximum Swap

MediumarrayExpected: O(n) time, O(1) spaceInterview Context

Problem

Given a non-negative integer, swap two digits at most once to get the maximum valued number.

Loading...