Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4592220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:30:27+00:00 2026-05-21T22:30:27+00:00

We have an array of heights, representing the altitude along a walking trail. Given

  • 0

We have an array of heights, representing the altitude along a walking trail. Given start/end indexes into the array, return the number of “big” steps for a walk starting at the start index and ending at the end index. We’ll say that step is big if it is 5 or more up or down. The start and end index will both be valid indexes into the array with start <= end.

bigHeights({5, 3, 6, 7, 2}, 2, 4) → 1      
bigHeights({5, 3, 6, 7, 2}, 0, 1) → 0     
bigHeights({5, 3, 6, 7, 2}, 0, 4) → 1     

Im stuck with this problem and unable to proceed further
The function signature is as below::
public int bigHeights(int[] heights, int start, int end){ }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:30:28+00:00Added an answer on May 21, 2026 at 10:30 pm

    You just have to go through the heights array, compute the absolute value of differences, and count:

    public int bigHeights(int[] heights, int start, int end){ 
        int bigsteps = 0;
        for (int i = start + 1; i <= end; i++) {
            if (Math.abs(heights[i] - heights[i - 1]) >= 5)
                bigsteps++;
        }
        return bigsteps;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an array of heights, representing the altitude along a walking trail. Given
I have a Width and Height parametr. I have been given an array of
I have a two dimensional array that I need to load data into. I
You have: val array = new Array[Array[Cell]](height, width) How do you initialize all elements
In PHP I have an array that looks like this: $array[0]['width'] = '100'; $array[0]['height']
I have array: array( 0 => new SomeClass(1), 1 => new SomeClass(2), 2 =>
I have array of objects: var aoo = [{},{},{},....{},{},{}]; I need a optimized function
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.