-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ackku] week 2 #713
[ackku] week 2 #713
Conversation
public int climbStairs(int n) { | ||
return dfs(n, new HashMap<>()); | ||
} | ||
|
||
private int dfs(int n, Map<Integer, Integer> memo) { | ||
if (n == 0) { | ||
return 1; | ||
} | ||
if (n < 0) { | ||
return 0; | ||
} | ||
if (memo.containsKey(n)) { | ||
return memo.get(n); | ||
} | ||
|
||
int result = dfs(n - 1, memo) + dfs(n - 2, memo); | ||
memo.put(n, result); | ||
|
||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DP만 생각했는데 DFS 풀이가 참신한것 같습니다 :)
arr[s.charAt(i) - 97]++; | ||
arr[t.charAt(i) - 97]--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
97 대신 'a' 를 쓰시면 좀 더 직관적으로 다가올것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2주차 문제풀이도 수고 많으셨습니다!
3주차에도 좋은 문제풀이 부탁드립니다 :)
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.