Skip to content

Commit b12780a

Browse files
authored
[ PS ] : Ailen Dictionary 수정
1 parent 89a79b3 commit b12780a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

alien-dictionary/uraflower.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const alienOrder = (words) => {
2222

2323
const minLen = Math.min(prev.length, current.length);
2424
for (let j = 0; j < minLen; j++) {
25-
graph[prev[j]].add(current[j]);
25+
if (prev[j] !== current[j]) {
26+
graph[prev[j]].add(current[j]);
27+
found = true;
28+
break;
29+
}
2630
}
2731
// 모순 처리
2832
if (!found && prev.length > current.length) {
@@ -63,7 +67,7 @@ const alienOrder = (words) => {
6367
}
6468
}
6569

66-
return output.reverse().join('')
70+
return output.reverse().join('');
6771
}
6872

6973

0 commit comments

Comments
 (0)