Given an array of N integers Arr_{1}, Arr_{2}, ….Arr_{N}, count number of subarrays of Arr which are strictly increasing. 
A subarray Arr_{[i, j]} is the array where 1 <= i < j <= N is a sequence of integers of Arr_{i}, Arr_{i+1}, ….Arr_{j}. A subarray Arr_{[i, j]} is strictly increasing if Arr_{i} < Arr_{i+1} < Arr_{i+2} < ……. < Arr_{j}.
Example 1:
Input: 
N = 6
Arr[] = {1, 3, 3, 2, 3, 5}
Output: 4
Explanation:
(1,3), (2, 3), (3, 5) and (2, 3, 5)
are the only increasing subarrays.
Example 2:
Input: 
N = 2
Arr[] = {1 5} 
Output: 1
Explanation:(1, 5) is the only increasing
subarray.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function countIncreasing() which takes the array of integers arr[] and n as parameters and returns a integer denoting the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 10^{7}
1 <= Arr_{i} <= 10^{7}

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:

	def countIncreasing(self,arr, n):
		# code here


Solutions:
class Solution:

	def countIncreasing(self, arr, n):
		(l, r) = (0, 1)
		count = 0
		while r < len(arr):
			if arr[r] > arr[r - 1]:
				count += r - l
			else:
				l = r
			r += 1
		return count


def countIncSub(arr, n):
	(fi, li) = (0, 0)
	state = 0
	result = 0
	for i in range(n - 1):
		if arr[i] < arr[i + 1]:
			state = 1
			li += 1
		else:
			if state:
				nTotal = li - fi + 1
				result += nTotal * (nTotal + 1) // 2 - nTotal
			state = 0
			fi = i
			li = i
	nTotal = li - fi + 1
	result += nTotal * (nTotal + 1) // 2 - nTotal
	return result

class Solution:

	def countIncreasing(self, arr, n):
		return countIncSub(arr, n)


class Solution:

	def countIncreasing(self, arr, n):
		left = 0
		ans = 0
		for (idx, n) in enumerate(arr):
			if idx > 0 and n <= arr[idx - 1]:
				left = idx
			ans += idx - left
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		last = arr[0]
		j = 0
		count = 0
		for i in range(1, n):
			if arr[i] > last:
				count += i - j
			else:
				j = i
			last = arr[i]
		return count


class Solution:

	def countIncreasing(self, arr, n):
		c = 1
		ans = 0
		for i in range(n - 1):
			if arr[i + 1] > arr[i]:
				c += 1
			else:
				ans += int((c - 1) * c / 2)
				c = 1
		if c > 1:
			ans += int((c - 1) * c / 2)
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		dp = [0] * len(arr)
		for i in range(1, len(arr)):
			if arr[i] > arr[i - 1]:
				dp[i] = 1 + dp[i - 1]
		return sum(dp)


import math

class Solution:

	def countIncreasing(self, arr, n):
		q = 0
		p = 1
		for i in range(n - 1):
			if arr[i + 1] > arr[i]:
				p += 1
			elif p > 1:
				q += math.factorial(p) // (2 * math.factorial(p - 2))
				p = 1
		if p > 1:
			q += math.factorial(p) // (2 * math.factorial(p - 2))
		return q


class Solution:

	def countIncreasing(self, arr, n):
		cnt = 1
		out = 0
		for i in range(n - 1):
			if arr[i] < arr[i + 1]:
				cnt += 1
			else:
				out += (cnt - 1) * cnt // 2
				cnt = 1
		if cnt > 1:
			out += (cnt - 1) * cnt // 2
		return out


class Solution:

	def countIncreasing(self, arr, n):
		count = 0
		countz = 0
		for i in range(n - 1):
			if arr[i] < arr[i + 1]:
				count += 1
			elif count > 0:
				countz += count * (count + 1) // 2
				count = 0
		if count > 0:
			countz += count * (count + 1) // 2
		return countz


class Solution:

	def countIncreasing(self, arr, n):
		allCount = 0
		currCount = 0
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				currCount += 1
				allCount += currCount
			else:
				currCount = 0
		return allCount


class Solution:

	def countIncreasing(self, a, n):
		len = 1
		cnt = 0
		for i in range(n - 1):
			if a[i + 1] > a[i]:
				len += 1
			else:
				cnt += len * (len - 1) // 2
				len = 1
		if len > 1:
			cnt += len * (len - 1) // 2
		return cnt


class Solution:

	def countIncreasing(self, arr, n):
		(p, q) = (0, 0)
		ans = 0
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				q += 1
			else:
				ans += (q - p + 1) * (q - p) // 2
				(p, q) = (i, i)
		ans += (q - p + 1) * (q - p) // 2
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		p = 0
		c = 0
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				c += i - p
			else:
				p = i
		return c


class Solution:

	def countIncreasing(self, arr, n):
		ans = 0
		count = 0
		i = 0
		while i < n - 1:
			count = 0
			while i < n - 1 and arr[i] < arr[i + 1]:
				count += 1
				i += 1
			ans += count * (count + 1) // 2
			i += 1
		return ans


class Solution:

	def countIncreasing(self, a, n):
		ans = 0
		l = 1
		for i in range(1, n):
			if a[i - 1] < a[i]:
				l += 1
			else:
				ans += l * (l - 1) // 2
				l = 1
		if l > 1:
			ans += l * (l - 1) // 2
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		count1 = 0
		count2 = 1
		for i in range(n - 1):
			if arr[i] < arr[i + 1]:
				count2 += 1
			else:
				count1 += (count2 - 1) * count2 // 2
				count2 = 1
		count1 += (count2 - 1) * count2 // 2
		return count1


class Solution:

	def countIncreasing(self, arr, n):
		if len(arr) < 2:
			return 0
		cnt = 0
		if arr[1] > arr[0] and len(arr) == 2:
			return 1
		r = 1
		l = 0
		f1 = None
		f2 = None
		for i in range(1, n - 1):
			f1 = arr[i - 1] < arr[i]
			f2 = arr[i] < arr[i + 1]
			if f1 and f2:
				r += 1
			elif not f1 and f2:
				r = i + 1
				l = i
			elif not f1 and (not f2):
				l = i + 1
				r = i + 1
			elif f1 and (not f2):
				cnt += (r - l) * (r - l + 1) // 2
		if f2:
			cnt += (r - l) * (r - l + 1) // 2
		return cnt


class Solution:

	def countIncreasing(self, arr, n):
		count = 0
		i = 0
		j = 0
		while i < n - 1:
			if j == n - 1 or arr[j] >= arr[j + 1]:
				length = j - i + 1
				count += length * (length - 1) / 2
				j = i = j + 1
			else:
				j += 1
		return int(count)


class Solution:

	def countIncreasing(self, arr, n):
		count = 0
		ln = 1
		for i in range(n - 1):
			if arr[i + 1] > arr[i]:
				ln += 1
			else:
				count += (ln - 1) * ln // 2
				ln = 1
		if ln > 1:
			count += ln * (ln - 1) // 2
		return count


class Solution:

	def countIncreasing(self, arr, n):
		rst = 0
		numIncWid = [1] * n
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				numIncWid[i] = numIncWid[i - 1] + 1
				rst = rst + (numIncWid[i] - 1)
		return rst


class Solution:

	def countIncreasing(self, a, n):
		res = 0
		count = 1
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				count += 1
			elif count > 1:
				res += count * (count - 1) // 2
				count = 1
		if count > 1:
			res += count * (count - 1) // 2
			count = 1
		return res


class Solution:

	def countIncreasing(self, arr, n):
		l = [0]
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				l.append(l[-1] + 1)
			else:
				l.append(0)
		return sum(l)


class Solution:

	def countIncreasing(self, arr, n):
		k = 0
		temp = 1
		for i in range(0, n - 1):
			if arr[i] < arr[i + 1]:
				temp += 1
			else:
				k += temp * (temp - 1) // 2
				temp = 1
		k += temp * (temp - 1) // 2
		return k


class Solution:

	def countIncreasing(self, arr, n):
		cur_len = 0
		count = 0
		cur_val = -1
		for i in range(n):
			val = arr[i]
			if val > cur_val:
				cur_len += 1
				count += cur_len - 1
			else:
				cur_len = 1
			cur_val = val
		return count


import math

class Solution:

	def countIncreasing(self, arr, n):
		c = 0
		l = 1
		for i in range(n - 1):
			if arr[i] < arr[i + 1]:
				l += 1
			else:
				c += l * (l - 1) // 2
				l = 1
		if l > 1:
			c += l * (l - 1) // 2
		return c


class Solution:

	def countIncreasing(self, arr, n):
		ans = 0
		small_index = 0
		for index in range(1, n):
			if arr[index] > arr[index - 1]:
				ans += index - small_index
			else:
				small_index = index
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		i = 1
		t = arr[0]
		ans = 0
		while i < n:
			c = 0
			while i < n and arr[i] > arr[i - 1]:
				i += 1
				c += 1
			i += 1
			ans += c * (1 + c) // 2
		return ans


class Solution:

	def countIncreasing(self, arr, n):
		length = 1
		res = 0
		for i in range(0, n - 1):
			if arr[i + 1] > arr[i]:
				length += 1
			else:
				res += (length - 1) * length / 2
				length = 1
		if length > 1:
			res += (length - 1) * length / 2
		return int(res)


class Solution:

	def countIncreasing(self, arr, n):
		subarrays = 0
		m = 1
		for i in range(1, n + 1):
			if i < n and arr[i] > arr[i - 1]:
				m += 1
			else:
				subarrays += m * (m - 1) // 2
				m = 1
		return subarrays