Find Arrays In An Array

In a given array, find the number of sub-arrays that have the following properties:

  1. The first and the last number of sub-array is the same.
  2. A sub-array has more than one number in it.

Submit number of such sub-arrays as answer.

The array is described in file AinA.txt. First number (\( 10^{5} \)) is the number of elements in the given array. The rest of it are numbers that go in the array.

Answer is 5. With blue are marked all satisfactory sub-arrays

Answer is 5. With blue are marked all satisfactory sub-arrays

Example with array of 8 elements.

Array: 3 1 7 5 5 7 3 7

\[\]

\[\]

Input Format and Details:

  • Link to input
  • The first line contains \(N\). The next line contains \(N\) space seperated integers which constitute the array.
  • All integers, including the answer are less than \(10^9\)

Questions can be asked here.

×

Problem Loading...

Note Loading...

Set Loading...