Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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 Alil, 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. Write a function: int solution(vector &A); that, given a non-empty array A containing N integers, denoting the heights of the students, returns the minimum number of rows created For example, given A-[5,4, 3, 6, 1], the function should return 2 Students will arrive in sequential order from AlO] to AIN-1]. So, the first student will have height 5, the second student will have height = 4, and so on. For the first student, there is no row, so the student will create a new row Row1[5]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions