Microsoft | OA | Maximum Length Of Square
Anonymous User
912

Given M number of 1x1 squares and N number of 2x2 squares, find the maximum length of square that can be formed using them. Its not mandatory to use all the squares.
Examples: (M,N)

  1. (8,0) -> 2 (4 1x1 squares used, max length of side = 2)
  2. (9,0) -> 3 ( all 9 1x1 squares used, max length of side =3)
  3. (0,18) -> 8 ( 16 squares used, max length = 8)
  4. (13, 3) -> 5 (arrange 3 2x2 in L shape, add 4 1x1 to the missing piece arrange 9 1x1 to the extra length and breadth of the square)
Comments (1)