goden1601

package
v0.0.0-...-b071cee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 0 Imported by: 0

README

面试题 16.01.交换数字

1. 题目描述

编写一个函数,不用临时变量,直接交换 numbers = [a, b]ab 的值。

示例:


输入: numbers = [1,2]
输出: [2,1]

提示:

  • numbers.length == 2
  • -2147483647 <= numbers[i] <= 2147483647

标签 位运算 数学

2. 解题

不用临时变量交换a,b

  1. a = a+b
  2. b = a-b
  3. a = a-b

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL