leetcode.com/problems/plus-one/
Plus One - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
형변환해서 더한다음에 자릿수에 맞춰서 끼워넣었는데
문제에서 원하는건 단순 포문인듯.
[]int를 string으로 바꿔보기도 하고
func intToString(digits []int) string {
b := ""
for _, v := range digits {
b += strconv.Itoa(v)
}
return b
}
big int 패키지도 사용
x, _ := new(big.Int).SetString(stringInt, 10)
y := big.NewInt(1)
n := x.Add(x, y) //plus one
intString := n.String() //to string
고랭에 big int 리미트는 없다고 한다. ㄷ ㄷ
What is the max value of bigint | golang blog
ispycode.com
strings 패키지좀 봐야겠다.
pkg.go.dev/strings?utm_source=gopls
strings · pkg.go.dev
Package strings implements simple functions to manipulate UTF-8 encoded strings. For information about UTF-8 strings in Go, see https://blog.golang.org/strings. func Compare(a, b string) int func Contains(s, substr string) bool func ContainsAny(s, chars st
pkg.go.dev
'hello world > algorithm' 카테고리의 다른 글
오늘의 알고리즘: Two Sum (1. LeetCode) (0) | 2021.01.15 |
---|---|
오늘의 알고리즘: Plus One (283. LeetCode) (0) | 2021.01.15 |
오늘의 알고리즘: Plus One (66. LeetCode) (0) | 2021.01.15 |
오늘의 알고리즘: Intersection of Two Arrays II (350. LeetCode) (0) | 2021.01.13 |
오늘의 알고리즘: Single Number (136. LeetCode) (0) | 2021.01.12 |
오늘의 알고리즘: Rotate Array (217. LeetCode) (0) | 2021.01.08 |