INSTAMOJO Online Assessment Interview Question | On-Campus(2024)

Question · Posted Jun 2026

Problem: Number of Pairs of Interchangeable Rectangles Given a 2D integer array rectangles, where rectangles[i] = [widthi, heighti], two rectangles are considered interchangeable if they have the same width-to-height ratio. Return the total number of interchangeable rectangle pairs. Example Input: rectangles = [[4,8],[3,6],[10,20],[15,30]] Output: 6 Explanation: All rectangles have ratio: 4/8 = 1/2 3/6 = 1/2 10/20 = 1/2 15/30 = 1/2 Number of pairs: 4C2 = 6

The full answer & interview discussion are available to premium members.

Log in Create a free account