Problem Β· Array

Nums That Are Divisible by N πŸ‹

● EasyTwo SigmaINTERNOA

The agency is giving you an int num named N and an arr of ints called arr[n].

Ur task -

  • 1. Find two nums with indices a & b (where b > a)
  • 2. Figure out the toal of the two nums
  • 3. Make sure the total is divisible by N
  • Finally, return the number of special pairs that meet the criteria outlined in tasks 1 through 3 πŸ₯‚
  • Examples
    01 Β· Example 1
    N = 3
    arr = [5, 4, 3, 2, 1]
    return = 4
    We can that there are FOUR pairs that meet the criteria outlined in task 1 through task 3 above πŸ‘† arr[0] + arr[1] = 1 + 2 = 3, 3 βž— 3 = 1 arr[0] + arr[4] = 1 + 5 = 6, 6 βž— 3 = 2 arr[1] + arr[3] = 2 + 4 = 6, 6 βž— 3 = 2 arr[3] + arr[4] = 4 + 5 = 9, 9 βž— 3 = 3 So, 4 should be returned. For original prompt, pls refer source image.
    Constraints
  • 1 <= N <= 109
  • 1 <= len of arr <= 105
  • 1 <= arr[i] <= 109
  • More Two Sigma problems
    drafts saved locally
      public int sumBeingAbletoBeDivisibleByN(int N, int[] arr) {
          // write your code here (lc1010 might help)
    
      }
      
    N3
    arr[5, 4, 3, 2, 1]
    expected4
    checking account