Maximum 69 Number
Updated
Problem statement
You are given a positive integer whose decimal digits are only 6 and 9. Change at most one digit and return the largest possible integer.
Function
maximum69Number(num: int) → intExamples
Example 1
num = 9669return = 9969Changing the first six produces the largest result.
Example 2
num = 9999return = 9999No change can improve the number.
Constraints
1 <= num <= 10^9.- Every decimal digit is
6or9.
Source note: Author-written prompt excerpt retained for source fidelity.
More HSBC interview questions
- Second Distinct Largest ElementONSITE INTERVIEW · Seen Oct 2026
- Organization Reputation After Employee DeparturesOA · Seen Nov 2026
- Remove Vowels from a StringOA · Seen Nov 2026
- Minimum Deletion Cost for Distinct Adjacent CharactersOA · Seen Oct 2026
- Distinct Products After Removing One ElementOA · Seen Sep 2026
- Minimum Cleaning Robot RunsOA · Seen Sep 2026
- Minimum Satellite Data Transfer IterationsOA · Seen Aug 2026
- Find ID of SoldierOA · Seen Jun 2026
- Find Most Frequently Purchased ProductsOA · Seen Jun 2026
- Minimum Markers to Clear Line SegmentsOA · Seen Nov 2025
Similar questions at other companies
- Maximize the Chance of Selecting the Best CandidateGoogle · ONSITE INTERVIEWGoogle interview questions
- Fewest Bills and CoinsCapital One · ONSITE INTERVIEWCapital One interview questions
- Spend a Budget Across Five Price TiersExpedia · ONSITE INTERVIEWExpedia interview questions
- Integer BreakAmazon · ONSITE INTERVIEW
- Maximum Bananas Delivered by a CamelStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
- UCB1 Multi-Armed Bandit TraceWayfair · ONSITE INTERVIEWWayfair interview questions
- Reach a Target by Adding CoordinatesJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
- Server InvestmentRippling · OARippling interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Particle Moves to TargetCresta · OACresta interview questions