PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/Airbnb

Find smallest permutation under constraints

Last updated: Apr 19, 2026

Quick Overview

This question evaluates digit-manipulation and combinatorial permutation skills, along with numeric ordering and representation concerns such as leading zeros and overflow handling in the Coding & Algorithms domain.

  • medium
  • Airbnb
  • Coding & Algorithms
  • Software Engineer

Find smallest permutation under constraints

Company: Airbnb

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given a non-negative integer `n`, consider its decimal digits as a multiset (digits can repeat). 1) Return the **smallest possible integer** that can be formed by rearranging the digits of `n`, **allowing leading zeros** (i.e., you are allowed to place `0` at the front; the result is still treated as an integer value). 2) Follow-up: Given an additional integer `lowerBound`, return the **smallest integer strictly greater than `lowerBound`** that can be formed by rearranging the digits of `n`. If no such number exists, return an indication such as `-1`. ### Example - `n = 178`: smallest permutation (allow leading zeros) is `178`. - Follow-up: `n = 178`, `lowerBound = 200` → answer is `718`. ### Constraints - You may assume `n` fits in 32-bit signed integer input, but intermediate permutations may exceed 32-bit; define how you handle overflow (e.g., use 64-bit or strings).

Quick Answer: This question evaluates digit-manipulation and combinatorial permutation skills, along with numeric ordering and representation concerns such as leading zeros and overflow handling in the Coding & Algorithms domain.

Related Interview Questions

  • Find Optimal Property Combination - Airbnb (medium)
  • Determine Exact Layover Booking - Airbnb (medium)
  • Solve Linked-List and Iterator Problems - Airbnb
  • Implement Text Layout and Query Parsing - Airbnb (easy)
  • Parse Query Parameters Into a Map - Airbnb (medium)
Airbnb logo
Airbnb
Feb 12, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
36
0
Coding Console
Loading...

Given a non-negative integer n, consider its decimal digits as a multiset (digits can repeat).

  1. Return the smallest possible integer that can be formed by rearranging the digits of n , allowing leading zeros (i.e., you are allowed to place 0 at the front; the result is still treated as an integer value).
  2. Follow-up: Given an additional integer lowerBound , return the smallest integer strictly greater than lowerBound that can be formed by rearranging the digits of n . If no such number exists, return an indication such as -1 .

Example

  • n = 178 : smallest permutation (allow leading zeros) is 178 .
  • Follow-up: n = 178 , lowerBound = 200 → answer is 718 .

Constraints

  • You may assume n fits in 32-bit signed integer input, but intermediate permutations may exceed 32-bit; define how you handle overflow (e.g., use 64-bit or strings).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Airbnb•More Software Engineer•Airbnb Software Engineer•Airbnb Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.