Company: infoedge

Difficulty: medium

Problem Statement

You are given a positive integer N and an array nums of distinct integers. Your task is to find the sum of lower bounds of factors of the integer N in the array nums . Lower bound is defined as the greatest element of nums that is strictly smaller than the given factor. For example, for the factor 3 and nums array {1,2,3,4}, 2 is the lower bound because 2 is the greatest element strictly smaller than 3. The integer 0 is guaranteed to be present in the array nums . Input Format The first line contains the integer N . The second line contains an integer m denoting the length of the array. In the next line, m-spaced integers denote the array elements a i . Constraints 2 <= N <= 10 9 1 <= m <= 10 5 , all elements lie in the range [0, 10 5 ] Output Format Return an integer denoting the sum of lower bounds of factors. Sample Input 30 6 0 5 10 15 20 25 Sample Output 45 Explanation For N=30, the unique factors are 2, 3, 5, 6, 10, 15, and 30. For the factor 2, the greatest integer s

More infoedge OA questionsInterview experiences