Feat: representN #7
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
여러 고비가 있었습니다.
최소값을 bottom-up으로 풀어야 할것 같았습니다.
일단 먼저 뭘 메모이제이션 할까에 대해서 고민을 해봤습니다.
먼저 x(1)가 있을 수 있고
x + x(2)
x - x(2)
x * x(2)
x / x(2)
xx(2)
가 있을 수 있습니다
그러고 나서는 (3)에선
(2) + (1)
(2) - (1)
(2) * (1)
(2) / (1)
(1) + (2)
(1) - (2)
(1) * (2)
(1) / (2)
xxx(3)
이런 경우들이 있습니다. 그래서 이 숫자의 갯수를 기준으로 2D arraylist를 만들어서
0 index에는 숫자하나
1에는 두개짜리
2에는 세개짜리 이렇게 저장을 하고,
저장하는 과정에서도 앞에 이미 계산했던것들을 사용해서 쓸 수 있게
getPair함수를 써서 가능성이 있는 짝리스트를 먼저 구한다음 for문을 돌면서 저장했던것을 갖다가 썼습니다.여기서 교환법칙을 고려할 필요는 없었던 이유가 저는 모든 짝 리스트를 다 구했기 때문입니다.
예를들어 3숫자이면
(1) - (2)
(2) - (1)
이 두 경우를 모두 페어로 짝리스트를 구해서 구했기 때무에 상관이 없었습니다.
그리고 마지막에 문제가 되었던게 제가 바보처럼 문제를 읽지 못해서 예외처리를 못한점과,
xxx이렇게 숫자가 붙어서 오는경우 숫자를 이상하케 생성해서 이에요
그래서 걍 숫자 제너레이터 만듬 그러니 해결~