Go语言leetcode刷题例子
leetcode刷题例子go语言编写大家相互学习一下unc main() { //字符串类型一维数组排序 //strs := []string{"eat", "tea", "tan", "ate", "nat", "bat"} //sort.Slice(strs, func(i, j int) bool { // return strs[i] < strs[j] //}) //fmt.Printf("%v\n", strs)
//数字类型一维数组排序 nums := []int{1, 5, 9, 3, 4, 2, 6, 8, 22} //nums = sortBubble(nums) //nums = sortSelect(nums) sortQuick(nums, 0, len(nums)-1) fmt.Printf("%v\n", nums)
//sort.Slice(nums, func(i, j int) bool { // return nums[i] < nums[j] //}) //fmt.Printf("%v\n", nums)}
用户评论