diff --git a/Find Closest Number to Zero - Leetcode 2239/Find Closest Number to Zero - Leetcode 2239.go b/Find Closest Number to Zero - Leetcode 2239/Find Closest Number to Zero - Leetcode 2239.go new file mode 100644 index 0000000..4184151 --- /dev/null +++ b/Find Closest Number to Zero - Leetcode 2239/Find Closest Number to Zero - Leetcode 2239.go @@ -0,0 +1,20 @@ +package solution + +func abs(a int) int { + if a < 0 { + return a * -1 + } + return a +} + +func findClosestNumber(nums []int) int { + closeNum := nums[0] + for i:=1; i closeNum{ + closeNum = nums[i] + } + } + return closeNum +}