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) = 4
Returns (boolean) true

Example 2

Input
nums (int[]) = [1,2,2,3]
size (int) = 4
Returns (boolean) false

Example 3

Input
nums (int[]) = [5]
size (int) = 1
Returns (boolean) true

Compare 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 true
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.