TachyonCalculus
Haryo Bimo
Jakarta Raya, Indonesia
Qui desiderat pacem, praeparet bellum
Qui desiderat pacem, praeparet bellum
Currently Offline
Information
Submission for Leetcode Problem 738. Monotone Increasing Digits (Medium)
[Golang] Greedy

Problem link [leetcode.com]
I don't know what to write so here's my recently accepted Leetcode submission:

func monotoneIncreasingDigits(n int) int {
⠀⠀⠀mult := 1
⠀⠀⠀result := 0
⠀⠀⠀next := math.MaxInt32
⠀⠀⠀
⠀⠀⠀for n > 0 {
⠀⠀⠀⠀⠀⠀curr := n % 10
⠀⠀⠀⠀⠀⠀multiple := mult * curr

⠀⠀⠀⠀⠀⠀if curr > next {
⠀⠀⠀⠀⠀⠀⠀⠀⠀result = multiple - 1
⠀⠀⠀⠀⠀⠀⠀⠀⠀next = result / mult
⠀⠀⠀⠀⠀⠀} else {
⠀⠀⠀⠀⠀⠀⠀⠀⠀result = multiple + result
⠀⠀⠀⠀⠀⠀⠀⠀⠀next = curr
⠀⠀⠀⠀⠀⠀}

⠀⠀⠀⠀⠀⠀mult *= 10
⠀⠀⠀⠀⠀⠀n /= 10
⠀⠀⠀}

⠀⠀⠀return result
}
Screenshot Showcase
Furai Drift
Recent Activity
51 hrs on record
last played on Jun 5
745 hrs on record
last played on Jun 1
1.9 hrs on record
last played on May 31
Comments
Dec 6, 2014 @ 7:18pm 
Hi bim :3