Skip to content

Commit 4b2f02f

Browse files
committed
👌 IMPROVE: optimize the reverse function
1 parent 2741c8c commit 4b2f02f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

data_structure/binary_tree.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,7 @@ func zigzagLevelOrder(root *TreeNode) [][]int {
640640
}
641641
func reverse(nums []int) {
642642
for i := 0; i < len(nums)/2; i++ {
643-
t := nums[i]
644-
nums[i] = nums[len(nums)-1-i]
645-
nums[len(nums)-1-i] = t
643+
nums[i], nums[len(nums)-1-i] = nums[len(nums)-1-i], nums[i]
646644
}
647645
}
648646
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy