Convert to Base -2 Solutions in GoNumber 1017Difficulty MediumAcceptance 59.0%Link LeetCodeOther languages C++SolutionsGo solution by halfrost/LeetCode-Gopackage leetcode import "strconv" func baseNeg2(N int) string { if N == 0 { return "0" } res := "" for N != 0 { remainder := N % (-2) N = N / (-2) if remainder < 0 { remainder += 2 N++ } res = strconv.Itoa(remainder) + res } return res}package leetcode import "strconv" func baseNeg2(N int) string { if N == 0 { return "0" } res := "" for N != 0 { remainder := N % (-2) N = N / (-2) if remainder < 0 { remainder += 2 N++ } res = strconv.Itoa(remainder) + res } return res }