Smallest Binary-Digit Multiple
Updated
Problem statement
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) → StringExamples
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
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