-
-
Notifications
You must be signed in to change notification settings - Fork 245
[ysle0] Week2 #742
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
[ysle0] Week2 #742
Changes from 4 commits
4666f02
3f1552f
3223589
3057d82
ed5382d
700c896
0b703de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package climbing_stairs | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func climbStairs(n int) int { | ||
return fibo(n) | ||
} | ||
|
||
func fibo(n int) int { | ||
ret := []int{0, 1} | ||
|
||
for i := 2; i <= n; i++ { | ||
ret = append(ret, ret[i-1]+ret[i-2]) | ||
} | ||
|
||
ret = ret[len(ret)-2:] | ||
fmt.Printf("ret=%v\n", ret) | ||
sum := 0 | ||
for _, n := range ret { | ||
sum += n | ||
} | ||
return sum | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package valid_anagram | ||
|
||
func isAnagram(s string, t string) bool { | ||
ht := make(map[rune]int, len(s)) | ||
for _, r := range s { | ||
ht[r]++ | ||
} | ||
|
||
for _, r := range t { | ||
cnt, ok := ht[r] | ||
if !ok { | ||
return false | ||
} | ||
|
||
|
||
ht[r] -= 1 | ||
if cnt-1 < 0 { | ||
return false | ||
} | ||
} | ||
|
||
for _, v := range ht { | ||
if v > 0 { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} |
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.
javascript의 slice 메소드가 이렇게 다르게 생겼군요!
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.
네.. 저도 처음에 이렇게 slicing 하는 것 보고 되게 신기했었어요 ㅎㅎ