{"id":"88392834-47b4-4095-bf51-0be7bb205cc4","name":"Roof Top","description":"1. You are given an array which represents heights of consecutive buildings.\r\n2. You can move from the roof of a building to the roof of next adjacent building. \r\n3. You need to find the maximum number of consecutive steps you can put forward such that you gain an increase in altitude with each step.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= A[i] &lt;= 10^5\r\n","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\nusing namespace std;\n\nint findMaxSteps(vector<int> &arr) {\n //write your code here\n return 0;\n}\n \nint main() {\n int n = 0;\n cin>>n;\n vector<int>arr(n);\n for(int i = 0 ; i < n; i++) {\n cin>>arr[i];\n }\n\n int ans = findMaxSteps(arr);\n cout<<ans<<endl;\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int findMaxSteps(int[]arr) {\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\r\n int[]arr = new int[n];\r\n for(int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int ans = findMaxSteps(arr);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"7\r\n1 4 5 2 3 2 4","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/wfK1ZgmumRo","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":"c70c9a83-5ba8-4bf3-b114-715ffe256b2c","name":"Roof Top","slug":"roof-top","type":1}],"next":{"id":"1b29c464-3b71-40cc-9311-a506a9e0058c","name":"Roof Top","type":3,"slug":"roof-top"},"prev":{"id":"b2c296f7-2f79-41d7-b26c-db9610f558b0","name":"Find Pair With Given Difference Medium MCQ","type":0,"slug":"find-pair-with-given-difference-medium-mcq"}}}

Roof Top

1. You are given an array which represents heights of consecutive buildings. 2. You can move from the roof of a building to the roof of next adjacent building. 3. You need to find the maximum number of consecutive steps you can put forward such that you gain an increase in altitude with each step.

{"id":"88392834-47b4-4095-bf51-0be7bb205cc4","name":"Roof Top","description":"1. You are given an array which represents heights of consecutive buildings.\r\n2. You can move from the roof of a building to the roof of next adjacent building. \r\n3. You need to find the maximum number of consecutive steps you can put forward such that you gain an increase in altitude with each step.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= A[i] &lt;= 10^5\r\n","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\nusing namespace std;\n\nint findMaxSteps(vector<int> &arr) {\n //write your code here\n return 0;\n}\n \nint main() {\n int n = 0;\n cin>>n;\n vector<int>arr(n);\n for(int i = 0 ; i < n; i++) {\n cin>>arr[i];\n }\n\n int ans = findMaxSteps(arr);\n cout<<ans<<endl;\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int findMaxSteps(int[]arr) {\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\r\n int[]arr = new int[n];\r\n for(int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int ans = findMaxSteps(arr);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"7\r\n1 4 5 2 3 2 4","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/wfK1ZgmumRo","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":"c70c9a83-5ba8-4bf3-b114-715ffe256b2c","name":"Roof Top","slug":"roof-top","type":1}],"next":{"id":"1b29c464-3b71-40cc-9311-a506a9e0058c","name":"Roof Top","type":3,"slug":"roof-top"},"prev":{"id":"b2c296f7-2f79-41d7-b26c-db9610f558b0","name":"Find Pair With Given Difference Medium MCQ","type":0,"slug":"find-pair-with-given-difference-medium-mcq"}}}
plane

Editor


Loading...

Roof Top

easy

1. You are given an array which represents heights of consecutive buildings. 2. You can move from the roof of a building to the roof of next adjacent building. 3. You need to find the maximum number of consecutive steps you can put forward such that you gain an increase in altitude with each step.

Constraints

1 <= N <= 10^6 1 <= A[i] <= 10^5

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

7 1 4 5 2 3 2 4

Sample Output

2

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode