r/computerscience • u/Homaderuvas • 2d ago
Help Drop some interesting algorithm problems
Hi guys please kindly share some interesting algorithm problems in the comment section. I did solve many algorithm problems on platforms like codeforces, atcoder, luogu and code chef etc.. looking for some unique ones that are quite challenging and interesting at the same time but kindly don't share open problems .
13
Upvotes
2
u/Disastrous-Doubt-909 2d ago
I adapted this from a maths problem
You are given an integer N and an array A containing exactly N + 1 integers.
Count the number of pairs of indices (i, j) such that:
0 ≤ i < j < N + 1
(A[i] - A[j]) is divisible by N.
Two elements with the same value are considered different if they occur at different indices.
Choose N large enough that an O(N²) brute-force solution will not pass.