Company: Myntra

Difficulty: medium

Problem Statement

Check Subarray Sum A cashier is holding n stacks of coins, given as array nums[] where nums[i] is the coin count in stack i. The cashier needs to pay out coins to k workers so that every worker ends up with the same number of coins and nothing is left unpaid. The cashier delegates this to an assistant, who may pick any single contiguous run of stacks and check whether the coins inside that run can be split evenly among the k workers with none remaining. Note: A run consisting of just one stack is not allowed for this check. The chosen run must span at least 2 stacks. Input Format The first line contains two integers n and k. The second line contains the n elements of the Array Output Format Print a single boolean variable result – whether Alice can distribute the amount to k person equally or not. Constraints 1 ≤ n ≤ 100000 0 ≤ nums[i] ≤ 2000 1 ≤ k ≤ 300 Sample Test Cases Sample Testcase 1 Input: 5 6 2 2 2 8 4 Output: 1 Explanation: The run [8, 4] adds up to 12 coins, which splits even

More Myntra OA questionsInterview experiences