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

#include <leetcode.h>

静态 Public 成员函数

static bool hasAlternatingBits (int n)
 

详细描述

在文件 leetcode.h1958 行定义.

成员函数说明

◆ hasAlternatingBits()

bool leetcode::binary_number_with_alternating_bits::Solution::hasAlternatingBits ( int  n)
static

在文件 leetcode.cpp5196 行定义.

5196 {
5197 stringstream ss;
5198 while(n != 0) {
5199 ss << n % 2;
5200 n /= 2;
5201 }
5202 string str;
5203 ss >> str;
5204 for(int i = 0; i + 1 < str.length(); i++) {
5205 if(str[i] == str[i + 1]) {
5206 return false;
5207 }
5208 }
5209 return true;
5210 }

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


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