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
75 hrs on record
last played on 5 Jul
8.7 hrs on record
last played on 4 Jul
752 hrs on record
last played on 4 Jul
Comments
6 Dec, 2014 @ 7:18pm 
Hi bim :3