Skip to main content

Command Palette

Search for a command to run...

Find Indices of Stable Mountains

Published
1 min read
Find Indices of Stable Mountains
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

There are n mountains in a row, and each mountain has a height. You are given an integer array height where height[i] represents the height of mountain i, and an integer threshold.

A mountain is called stable if the mountain just before it (if it exists) has a height strictly greater than threshold. Note that mountain 0 is not stable.

Return an array containing the indices of all stable mountains in any order.

LeetCode Problem - 3285

class Solution {
    public List<Integer> stableMountains(int[] height, int threshold) {
        // Create a list to store the indices of stable mountains
        List<Integer> list = new ArrayList<>();

        // Loop through the height array, starting from the second element
        for (int i = 1; i < height.length; i++) {
            // Check if the previous height is greater than the given threshold
            if (height[i - 1] > threshold) {
                // If it is, add the current index to the list (i is stable)
                list.add(i);
            }
        }

        // Return the list of indices for stable mountains
        return list;
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.