CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
int main() {
int arr[] = { 58, 93,94,95,32,88,66,22,23,24,25,26};
// Shorter array
vector <int> vec;
// start of streak
int numStart = arr[0];
// end of streak
int numEnd = arr[0];
// true - on a streak , false - not on a streak
bool onStreak = false;
// loops over all the array
for( unsigned int a = 1; a < sizeof(arr) / sizeof(int); a = a + 1 ) {
// Now elemnt is greater than last elemnt in one
if(arr[a] - 1 == numEnd) {
// checks if there is a streak
if(onStreak) {
// continues streak
numEnd = arr[a];
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run