Skip to content

Commit 9c778d6

Browse files
committed
스트리밍
1 parent c068468 commit 9c778d6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

ALGORITHMS/스트리밍.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// 효율성 불통
2+
function solution(playList, time) {
3+
const pLen = playList.length;
4+
5+
const addList = playList.concat(playList);
6+
7+
const getCount = (start, end) => {
8+
let acc = 0,
9+
count = 0;
10+
addList.some((p) => {
11+
acc += p;
12+
if (acc > start) count++;
13+
14+
if (acc >= end) return true;
15+
});
16+
17+
return count;
18+
};
19+
20+
const sum = playList.reduce((acc, cur) => acc + cur, 0);
21+
if (sum < time) return pLen;
22+
23+
let result = 0;
24+
Array.from({ length: sum }).some((_, i) => {
25+
const res = getCount(i, i + time);
26+
if (res > result) result = res;
27+
});
28+
29+
return result;
30+
}

0 commit comments

Comments
 (0)