Amazon Interview | OA | Shrink Array
Anonymous User
1034

Given an array of numbers. Perform below operations

  1. Find the adjacent numbers which are not co prime.
  2. Delete those two numbers and replace with the LCM of two numbers.
    Example :: [2, 3 , 4 , 6, 7] output = [12,7]
    --> [2, 3, 12, 7] since (4, 6) is replaced with the lcm of two numbers - 12
    --> [2,12,7] since (3,12) is replaced with the lcm(3,12) - 12
    --> [12, 7] since(2,12) is replaced with the lcm(2,12) - 12

Please provide effiicient soluton

Comments (3)