fixed error when the list is empty (#637)
* feat: Add Go code to binary search recursion under divide and conquer * style: Code comment standardization * style: modify function comment * fix: fixed error when the list is empty * Update print_utils.go * Delete print_utils_test.go --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
da2c71d936
commit
8068c42688
@ -19,6 +19,10 @@ func PrintSlice[T any](nums []T) {
|
|||||||
|
|
||||||
// PrintList Print a list
|
// PrintList Print a list
|
||||||
func PrintList(list *list.List) {
|
func PrintList(list *list.List) {
|
||||||
|
if list.Len() == 0 {
|
||||||
|
fmt.Print("[]\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
e := list.Front()
|
e := list.Front()
|
||||||
// 强转为 string, 会影响效率
|
// 强转为 string, 会影响效率
|
||||||
fmt.Print("[")
|
fmt.Print("[")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user