Permute the Array
Practice
3.1 (27 votes)
Arrays
Data structures
Easy
Hash maps
Implementation
One Dimensional
Problem
41% Success 5939 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array consisting of $$N$$ integers. You need to determine whether any permutation of given array exist such that the sum of all subarrays of length $$K$$ are equal.

Input format :

  • The first line consist of $$T$$ denoting the number of testcases.
  • The first line of each testcase consist of two space seperated integers $$N$$ and $$K$$.
  • The second line of each testcase consist of $$N$$ space seperated integers denoting array elements.

Output format :

  • Print "YES" or "NO" for each testcase in a new line.

Constraints :

  • \(1 \le T \le 10 \)
  • \(1 \le K \le N \le 10^{6}\)
  • \(1 \le A_{i} \le 10^{5}\)
  • $$N$$ is divisible by $$K$$  i.e \(N\mod K=0\)

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
280 votes
Tags:
ApprovedData StructuresEasyOpenQueue
Points:20
30 votes
Tags:
ArraysData StructuresEasyOne-dimensional
Points:20
18 votes
Tags:
ArraysImplementation1-DC++Data Structures