1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ANTONII [103]
3 years ago
5

c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive

by one, sequentially (as their heights appear in A). For the i-th student, if there is a row in which all the students are taller than A[i], the student will stand in one of such rows. If there is no such row, the student will create a new row. Your task is to find the minimum number of rows created.
Computers and Technology
1 answer:
Lilit [14]3 years ago
4 0

The below code will help you to solve the given problem and you can execute and cross verify with sample input and output.

#include<stdio.h>

#include<string.h>

 int* uniqueValue(int input1,int input2[])

 {

   int left, current;

   static int arr[4] = {0};

   int i      = 0;

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

      {

         current = input2[i];

         left    = 0;

         if(current > 0)

         left    = arr[(current-1)];

      if(left == 0 && arr[current] == 0)

       {

       arr[current] = input1-current;

       }

       else

   {

       for(int j=(i+1);j<input1;j++)

       {

           if(arr[j] == 0)

           {

               left = arr[(j-1)];

               arr[j] = left - 1;

           }

       }

   }

}

return arr;

}

You might be interested in
Will give brainliest and good amount of points, no false answers.
nlexa [21]

The problem with the swap function is that it loses the value at the first index, as soon as it gets overwritten by the value at the second index. This happens in the first statement. To fix it, you need a helper variable.

First you're going to "park" the index at the first index in that helper variable, then you can safely overwrite it with the value at the second index. Then finally you can write the parked value to the second index:

var swap = function(array, firstIndex, secondIndex) {

let helper = array[firstIndex];

array[firstIndex]  = array[secondIndex];

array[secondIndex] = helper;

};

I hope this makes sense to you.

7 0
3 years ago
Which of the following need NOT be completed separately if a worksheet is prepared?
Anika [276]
C because you already have you sheet prepared
3 0
3 years ago
What are some of the challenges of note-taking? Check all that apply.
Anvisha [2.4K]

Explanation:

it can take up a great deal of time in class.

it can be distracting in the middle of a lecture.

it can cause the student to miss information.

3 0
3 years ago
Read 2 more answers
What is the output when you run the following program? print(3 + 7) print("2 + 3")
QveST [7]

print(3+7) will output 10, which is an integer.

print("2+3") will output 2+3, which is a string.

6 0
3 years ago
________ is a crime that uses mock (fake) sites to trick people into sharing information.
Elan Coil [88]
<span>Phishing is a crime that uses mock (fake) sites to trick people into sharing information.</span>
5 0
3 years ago
Other questions:
  • How do media and networks interact
    11·1 answer
  • Analyst is investigating proxy logs and found out that one of the internal user visited website storing suspicious java scripts.
    8·1 answer
  • Fill in the blank with the correct response.
    10·1 answer
  • What some one ask me if i am more of hardware or software person, what is that mean?
    6·1 answer
  • Create a function called "strip_r_o" that takes in a STRING and strips all the Rs and Os from the string. Also use a FOR loop in
    7·1 answer
  • What are the 2 things you are not sure about evaluating functions​
    7·2 answers
  • Describe the procedure for creating a table or spreadsheet in a presentation slide.
    7·2 answers
  • What option defines green computing?
    14·1 answer
  • FREE BRAINLIEST!!!
    14·2 answers
  • I really need the answer now!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!