Question:

Whoever can answer this java problem is a genious!!

by  |  earlier

0 LIKES UnLike

This was a problem that caused my AP class a lot of trouble. It took us 3 months to figure it out. The answer is really simple if you know a little java.

Given an array of scores, return true if each score is equal or greater than the one before. The array will be length 2 or more.

scoresIncreasing({1, 3, 4}) → true // this is what the output is

scoresIncreasing({1, 3, 2}) → false // supposed to look like.

scoresIncreasing({1, 1, 4}) → true

 Tags:

   Report

1 ANSWERS


  1. Here's one solution: value of flag is the value that indicates your specified condition:

    flag = true;

    j = scoresIncreasing.length

    for (i=0; i < j;i++)

    {

    if (scoresIncreasing[i] > scoresIncreasing[i+1])

      {

        flag = false;

        i = j;                    // terminate loop

      }

    }

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.