We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0e69dcc commit f714991Copy full SHA for f714991
1 file changed
live10/test104/문제3/조진우.js
@@ -0,0 +1,32 @@
1
+function solution(begin, target, words) {
2
+ let visit = [];
3
+ let box = [];
4
+ box.push([begin, 0]);
5
+
6
+ while (box.length > 0) {
7
+ let now = box.shift();
8
+ let txt = now[0];
9
+ let cnt = now[1];
10
11
+ if (txt === target) {
12
+ return cnt;
13
+ }
14
15
+ for (let i = 0; i < words.length; i++) {
16
+ let word = words[i];
17
+ let diff = 0;
18
+ for (let j = 0; j < word.length; j++) {
19
+ if (txt[j] !== word[j]) {
20
+ diff++;
21
22
23
24
+ if (diff === 1 && !visit.includes(word)) {
25
+ visit.push(word);
26
+ box.push([word, cnt + 1]);
27
28
29
30
31
+ return 0;
32
+}
0 commit comments