<html>
<head>
<meta charset="UTF-8">
<title>출력결과</title>
</head>
<!-- 학생의 키가 주어질 때, 앞에 있는 사람들보다 크면 보이고 작거나 같으면 보이지 않습니다 -->
<body>
<script>
function solution(arr) {
let answer = 0;
let max = 0;
for (let student of arr) {
if (max < student) {
max = student;
answer++;
}
}
return answer;
}
let arr = [130, 135, 148, 140, 145, 150, 150, 153];
console.log(solution(arr));
</script>
</body>
</html>
'개발공부 > 알고리즘' 카테고리의 다른 글
[Algorithm] 가위바위보 (0) | 2023.04.27 |
---|---|
[Algotithm] 큰 수 출력하기 (0) | 2023.04.26 |
[Algorithm] 중복 단어 제거하기 (메모리 관련 이야기) (0) | 2023.04.25 |
[Algorithm] 문자열 중복제거 (뭔가 이상함) (0) | 2023.04.24 |
[Algorithm] 가운대 문자 출력하기 (0) | 2023.04.24 |