We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4dda609 commit 448f895Copy full SHA for 448f895
1 file changed
src/Do-ho/implementation/pgs_영어끝말잇기/pgs_영어끝말잇기.js
@@ -0,0 +1,21 @@
1
+const solution = (n, words) => {
2
+ let [people, order] = [0, 0];
3
+ let prevText = null;
4
+ let wordSet = [];
5
+ const isNotPrevTextNull = () => prevText !== null;
6
+ const isNotMatchWord = (word) => prevText[prevText.length - 1] !== word[0];
7
+ const isContainWordSet = (word) => wordSet.includes(word);
8
+
9
+ for (let i=0; i<words.length; i++) {
10
+ const word = words[i];
11
+ if(isNotPrevTextNull() && (isNotMatchWord(word) || isContainWordSet(word))) {
12
+ people = (i % n) + 1;
13
+ order = Math.floor(i / n) + 1;
14
+ break;
15
+ }
16
+ prevText = word;
17
+ wordSet.push(word);
18
19
20
+ return [people, order];
21
+}
0 commit comments