-
[JS 알고리즘&자료구조] 해결 또는 단순화JavaScript/Basic 2023. 11. 1. 00:04
앞의 세가지 과정을 거쳤고 문제에 대한 해결책이 완전히 나온 상황이라면 이제는 코드를 통해 문제를 해결하기만 하면 된다. 하지만 모든 문제들이 순탄하게 해결되는 것은 아니다. 어떤 문제들은 앞선 과정을 거쳐도 해결책이 제대로 나오지 않는 경우가 있을 수 있고 또 어떤 문제들은 해결책이 나왔다고 해도 코드로 구현할 때 애를 먹을 수도 있다. 이 경우에는 단순화를 하는 것이다. 문제를 해결할 수 있으면 해결하고 아닌 경우에는 해결책에 도달하기 위한 수많은 방법들 중 아주 단순하게 해결할 수 있는 방법들을 찾아 적용시켜보는 것이다. (하드 코딩 등) 결과를 도출해낼 수 있는 많은 방법들 중 효율적이지만 생각해내기엔 어려운 방법을 생각하기보다는 당장 결과물을 출력해낼 수 있는 단순한 방법을 떠올려보는 것이다. (뭔가 수능 준비할 때 들었던 느낌🤣) 단순화를 하다보면 오히려 그 안에서 패턴이나 방법들을 찾게 되서 효율적인 해결 방법에 대한 힌트를 얻을 수도 있기 때문이다.
단순화를 위한 과정을 한번 살펴보자.
- 문제 해결 과정에서 어려움에 봉착하게 된다.
- 효율적으로 해결하는 방법은 생각하지 말고 최대한 단순하게 해결할 수 있는 방법으로 해결해본다. (하드 코딩 등)
- 후에 이러한 방법들을 통합시키면서 효율적으로 해결할 수 있는 방안에 도달한다.
'JavaScript > Basic' 카테고리의 다른 글
[JS 알고리즘&자료구조] 문제 해결 패턴 소개 (0) 2023.11.02 [JS 알고리즘&자료구조] 되돌아보기와 리팩터 (0) 2023.11.02 [JS 알고리즘&자료구조] 세부 분석 (1) 2023.10.31 [JS 알고리즘&자료구조] 구체적 예제들 (0) 2023.10.30 [JS 알고리즘&자료구조] 문제의 이해 (0) 2023.10.30