• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 30, 2024 |40 Views

PROBLEM OF THE DAY : 20/09/2024 | Facing the sun

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Saurabh Bansal We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given an array height representing the heights of buildings. You have to count the buildings that will see the sunrise (Assume the sun rises on the side of the array starting point).
Note: The height of the building should be strictly greater than the height of the buildings left in order to see the sun.
 

Examples :

Input: height = [7, 4, 8, 2, 9] Output: 3 Explanation: As 7 is the first element, it can see the sunrise. 4 can't see the sunrise as 7 is hiding it. 8 can see. 2 can't see the sunrise. 9 also can see
the sunrise.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/facing-the-sun2126/1