
[프로그래머스, Java] 단어 변환
·
CodingTest/Programmers
⭐ 아이디어모두를가지고~~ -> dfs (stack)가능한 최소의 경우 -> bfs (queue)begin hittarget cogwords 안에 target이 없으면 return 0(begin, count=0)을 stack에 넣고 시작while(!isEmpty)꺼낸값과 하나만 차이나는 단어 찾기 -> 어떻게 최적화? target의 index로 분기하기 현재 target(i) 와 pop(i)가 같으면 넘어가 다르다면 -> pop(i)를 target(i)로 변경한 전체 문자를 words에서 찾기 -> 찾았다면 해당 단어로 변경하고 count+1 하기 -> target과 같다면 answer 와 count를 크기비교하여 작은 값을 저장하기 ..