16.01专题

Leetcode :面试题 16.01. 交换数字(位运算)

面试题 16.01. 交换数字 编写一个函数,不用临时变量,直接交换numbers = [a, b]中a与b的值。 示例: 输入: numbers = [1,2] 输出: [2,1] 提示: numbers.length == 2 利用性质 a=b^a ^b; 只是换一下位置就OK了 class Solution {public:vector<int> swapNumbers(v

【LeetCode程序员面试金典】面试题 16.01. Swap Numbers LCCI

Write a function to swap a number in place (that is, without temporary vari­ ables). Example: Input: numbers = [1,2] Output: [2,1] Note: numbers.length == 2 来源:力扣(LeetCode) 链接:https://leetcode-cn.