Longest Subarray With Sum Divisible By K

Given an arr[] of integers and a positive integer k, find the longest subarray's length with the sum of the elements divisible by k. Examples:Input: arr[] = [2, 7, 6, 1, 4, 5], k = 3Output: 4Explanation: The subarray [7, 6, 1, 4] has sum = 18, which is divisible by
Read the full report on Geeksforgeeks
Story file
- Section
- Tech
- First reported by
- Geeksforgeeks
- Reporter
- geeksforgeeks
- Published
- Sunday, 18 October 2026, 12:01 am IST
- Coverage
- One outlet so far
How this page works. The Headline Update lists this report from Geeksforgeeks with a short summary and a link to the original. The original reporting and photograph belong to the publisher. Spotted an error in our summary? Tell our corrections desk.




