problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::single_number_iii::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< int > singleNumber (vector< int > &nums)
 

详细描述

在文件 leetcode.h3221 行定义.

成员函数说明

◆ singleNumber()

vector< int > leetcode::single_number_iii::Solution::singleNumber ( vector< int > &  nums)
static

在文件 leetcode.cpp9221 行定义.

9221 {
9222 int xorsum = 0;
9223 for(const int num: nums) {
9224 xorsum ^= num;
9225 }
9226 // 防止溢出
9227 const int lsb = xorsum == INT_MIN ? xorsum : xorsum & -xorsum;
9228 int type1 = 0, type2 = 0;
9229 for(const int num: nums) {
9230 if(num & lsb) {
9231 type1 ^= num;
9232 } else {
9233 type2 ^= num;
9234 }
9235 }
9236 return {type1, type2};
9237 }

被这些函数引用 leetcode::single_number_iii::TEST().


该类的文档由以下文件生成: