Side Largest Square 🟧
Updated
Problem statement
You have m square tiles of size 1 * 1 and n square tiles of size 2 * 2. Your task is to create the largest possible square using these tiles. Tiles may not overlap, and the resulting square should be filled (it should not contain empty spaces).
Let's now write a func called sideLargetstSquare(int m, int n) in the editor 👉
Task of your func:
- Find the len of the side of the largest square you can create. If no square can be created, func should return 0.
Function
sideLargetstSquare(m: int, n: int) → intExamples
Example 1
m = 8n = 0return = 2You can use four out of eight tiles to arrange them into 2 * 2 square. There are not enough tiles to create 3 * 3 square.
Example 2
m = 4n = 3return = 4
You can obtain 4 * 4 square by arranging four 1 * 1 tiles into a 2 * 2 square, and surrounding it by 2 * 2 tiles:
Example 3
m = 0n = 18return = 8You need to use sixteen 2 * 2 tiles to create the square. Not that not all the tiles are used.
Example 4
m = 13n = 3return = 5
One of the possible arrangements is shown in the following image:
Constraints
1 <= m, n <= 1,000,000,000
More Microsoft interview questions
- Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
- Authentication SystemOA · Seen Nov 2026
- Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
- Maximum String OperationsOA · Seen Nov 2026
- Minimum Cost to Process Priority TasksOA · Seen Nov 2026
- Most Visited Sprint MarkerOA · Seen Nov 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
- Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
- Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
- Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
- Perfect Squares Matching a PatternNielsen · OA
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Count Lucky Numbers in a RangeTarget · OA
- Cyber Beacon DetectionRippling · OARippling interview questions
- Souvenir Shop PurchasesAmazon · OA
- TikTok Video Relevance AdjustmentTikTok · OATikTok interview questions
- Paint the CeilingSnowflake · OASnowflake interview questions
- K-th Character in an Infinite StringArcesium · OAArcesium interview questions
Microsoft interview experiences
- Microsoft OA Questions, October 2026: 4 Experiences
- Microsoft Experienced SWE Phone Screen: 1 Experience
- Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
- Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
- Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
- Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)