HTMLify

LeetCode - Keep Multiplying Found Values by Two - Go
Views: 9 | Author: abh
func findFinalValue(nums []int, original int) int {
    for ;true; {
        f := false
        for _, n := range nums {
            if n == original {
                f = true
                break
            }
        }
        if f == false {
            break
        }
        for _, n := range nums {
            if n == original {
                original *= 2
                break
            }
        }
    }
    return original
}

Comments