Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Inorder Traversal and BST
Easy Accuracy: 59.68% Submissions: 916 Points: 2

Given an array arr of size N, write a program that returns 1 if array represents Inorder traversal of a BST, else returns 0.
Note: All keys in BST must be unique.

Example 1:

Input:
N = 3
arr = {2, 4, 5}
Output: 1
Explaination: Given arr representing
inorder traversal of a BST.


Example 2:

Input:
N = 3
arr = {2, 4, 1}
Output: 0
Explaination: Given arr is not representing
inorder traversal of a BST.

You don't need to read input or print anything. Your task is to complete the function isRepresentingBST() which takes the array arr[] and its size as input parameters and returns 1 if array represents Inorder traversal of a BST, else returns 0.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ N ≤ 103
1 ≤ arr[i] ≤ 103