Problem Statement :
Click here to Subscribe : Education inTalk
Q3 .
Find the number of students whose height is less than the height of their adjacent students.
Problem Statement :
A physical education teacher asks students to assemble in a straight line for the morning assembly.Given an array of N in which each element represents the height of the student in that position. The task here is to find the number of students whose height is less than the height of their adjacent students.
Input: 35, 15, 45,25,55
Output: 2 (35>15<45 and 45>25<55)
Explanation :
we take element at index 1 start checking the condition and those who satisfied the condition , will be our output .
[ there is no mean to take 1st and last element into the iteration as there are no adjacent element of both side ]
Code :
Comments
Post a Comment