We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89a79b3 commit b12780aCopy full SHA for b12780a
1 file changed
alien-dictionary/uraflower.js
@@ -22,7 +22,11 @@ const alienOrder = (words) => {
22
23
const minLen = Math.min(prev.length, current.length);
24
for (let j = 0; j < minLen; j++) {
25
- graph[prev[j]].add(current[j]);
+ if (prev[j] !== current[j]) {
26
+ graph[prev[j]].add(current[j]);
27
+ found = true;
28
+ break;
29
+ }
30
}
31
// 모순 처리
32
if (!found && prev.length > current.length) {
@@ -63,7 +67,7 @@ const alienOrder = (words) => {
63
67
64
68
65
69
66
- return output.reverse().join('')
70
+ return output.reverse().join('');
71
72
73
0 commit comments