Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(heights) {
- let answer = [];
- let len = heights.length;
- heights.reverse();
- heights.forEach((v, i) => {
- let bool = true;
- heights.forEach((value, index) => {
- if(v < value && i < index && bool){
- bool = false;
- answer.push(len - index);
- }
- })
- if(bool) answer.push(0);
- })
- return answer.reverse();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement