FastPrepSmallest Binary-Digit Multiple
Problems/Smallest Binary-Digit Multiple

Smallest Binary-Digit Multiple

Myntra logoMyntra● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Myntra onsite interview for interns. The task is to find the smallest number made only of the decimal digits 0 and 1 that is divisible by n. The report names BFS with modular arithmetic. It leaves out the order, the limits, what happens with leading zeros, and how to write the output. We filled those in.

Our version is about 94% the same as the reported question.

Given a positive integer n, return the numerically smallest positive decimal integer that is divisible by n and whose decimal representation contains only the digits 0 and 1.

The representation must begin with 1. Return the result as a string because it may not fit in a built-in integer type.

Function

smallestBinaryDigitMultiple(n: int) → String

Examples

Example 1

n = 2return = "10"

The decimal number 10 uses only allowed digits and is divisible by 2.

Example 2

n = 3return = "111"

Neither 1, 10, 11, 100, 101, nor 110 is divisible by 3; 111 is the first valid number.

Example 3

n = 7return = "1001"

The value 1001 equals 7 multiplied by 143.

Constraints

  • 1 <= n <= 20000.

More Myntra interview questions

  • Detect a Server RAM Capacity BreachONSITE INTERVIEW · Seen May 2026
  • Minimum Route Reversals to Warehouse ZeroONSITE INTERVIEW · Seen May 2026
  • Minimum Swaps to Group Values at Most KONSITE INTERVIEW · Seen May 2026
  • Maximum Capped Histogram Area After One RemovalOA · Seen May 2026

Similar questions at other companies

  • Minimum Moves for Two Knights to MeetAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Steps with Double and Floor-DivideBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Unit Conversion Across Independent FamiliesApple · PHONE SCREENApple interview questions
  • Count Reachable Values by Halving and DecrementingInfosys · OAInfosys interview questions
  • Frog Position After T SecondsInMobi · PHONE SCREENInMobi interview questions
  • Count Level-Order Traversals of a TreeBank of America · OABank of America interview questions
  • Reaching Points with Perfect-Square ObstaclesIMC Trading · OAIMC Trading interview questions
  • Broken CalculatorNutanix · OANutanix interview questions
  • Count Pasture Animal ArrangementsIntuit · OAIntuit interview questions
  • Tree Path GCDNewton School · PHONE SCREEN
All Myntra interview questionsSee Myntra hiring insights
Saved
class Solution {
    public String smallestBinaryDigitMultiple(int n) {
        // Return the smallest valid decimal representation.
    }
}
Checking account…