Learner Level
Implement the isArrayStrictlyIncreasing method that checks whether every array element is greater than the element before it.
The input contains an integer array nums and its length size. Your task is to check whether the array is strictly increasing.
An array is strictly increasing when every element is greater than the element before it. Equal values are not allowed. For example, [1,2,3,4] returns true, but [1,2,2,3] returns false.
Example 1
Input
nums (int[]) =
[1,2,3,4]size (int) =
4Returns (boolean)
trueExample 2
Input
nums (int[]) =
[1,2,2,3]size (int) =
4Returns (boolean)
falseExample 3
Input
nums (int[]) =
[5]size (int) =
1Returns (boolean)
trueCompare each element with the previous element.
If any current value is less than or equal to the previous value, the array is not strictly increasing and you can return false immediately. If the loop finishes, return true.
Pseudocode:
function isArrayStrictlyIncreasing(nums, size):
for i from 1 to size - 1:
if nums[i] <= nums[i - 1]:
return false
return trueReady to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run