{"id":"d63746c2-3b63-4d60-89bf-daf916c4d970","name":"Facing The Sun","description":"Given an array ht representing heights of buildings. You have to count the buildings which will see the sunrise (Assume : Sun rise on the side of array starting point).\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 10^6\r\n1 &lt;= H[i] &lt;= 10^8","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\nusing namespace std;\nint countBuildings(vector<int> &ht) {\n //write your code here\n return 0;\n}\nint main() {\n int n = 0;\n cin>>n;\n vector<int> ht(n);\n\n for (int i = 0; i < n; i++) {\n cin>>ht[i];\n }\n\n cout<<countBuildings(ht);\n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int countBuildings(int[]ht) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]ht = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n ht[i] = scn.nextInt();\r\n }\r\n\r\n System.out.println(countBuildings(ht));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n7 4 8 2 9","sampleOutput":"3","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"43382973-085c-46d2-b02e-9b49e341ecb7","name":"Facing The Sun","slug":"facing-the-sun","type":1}],"next":{"id":"9c4c8d69-29e8-47d8-90bb-3acfdc64a4ef","name":"Facing The Sun","type":3,"slug":"facing-the-sun"},"prev":{"id":"261aa04b-cca2-476a-92dc-ff2739a953cc","name":"Count Zeros Xor Pairs MCQ","type":0,"slug":"count-zeros-xor-pairs-mcq"}}}

Facing The Sun

Given an array ht representing heights of buildings. You have to count the buildings which will see the sunrise (Assume : Sun rise on the side of array starting point).

{"id":"d63746c2-3b63-4d60-89bf-daf916c4d970","name":"Facing The Sun","description":"Given an array ht representing heights of buildings. You have to count the buildings which will see the sunrise (Assume : Sun rise on the side of array starting point).\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 10^6\r\n1 &lt;= H[i] &lt;= 10^8","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\nusing namespace std;\nint countBuildings(vector<int> &ht) {\n //write your code here\n return 0;\n}\nint main() {\n int n = 0;\n cin>>n;\n vector<int> ht(n);\n\n for (int i = 0; i < n; i++) {\n cin>>ht[i];\n }\n\n cout<<countBuildings(ht);\n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int countBuildings(int[]ht) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]ht = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n ht[i] = scn.nextInt();\r\n }\r\n\r\n System.out.println(countBuildings(ht));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n7 4 8 2 9","sampleOutput":"3","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"43382973-085c-46d2-b02e-9b49e341ecb7","name":"Facing The Sun","slug":"facing-the-sun","type":1}],"next":{"id":"9c4c8d69-29e8-47d8-90bb-3acfdc64a4ef","name":"Facing The Sun","type":3,"slug":"facing-the-sun"},"prev":{"id":"261aa04b-cca2-476a-92dc-ff2739a953cc","name":"Count Zeros Xor Pairs MCQ","type":0,"slug":"count-zeros-xor-pairs-mcq"}}}
plane

Editor


Loading...

Facing The Sun

easy

Given an array ht representing heights of buildings. You have to count the buildings which will see the sunrise (Assume : Sun rise on the side of array starting point).

Constraints

1 <= N <= 10^6 1 <= H[i] <= 10^8

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

5 7 4 8 2 9

Sample Output

3

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode