当前位置:网站首页>Programmer interview golden code interview question 01.01. determine whether the character is unique
Programmer interview golden code interview question 01.01. determine whether the character is unique
2022-07-22 19:02:00 【yijun009】
Here is bool Array methods
#include <iostream>
#include<string>
using namespace std;
class Solution {
public:
bool isUnique(string astr) {
bool charRecord[100] = {
false };// All use false To initialize
for (int i = 0; i<int(astr.length()); i++){
if (charRecord[astr[i] - 'a'] == true)
return false;
else
charRecord[astr[i] - 'a'] = true;
}
return true;
}
};
void main(){
string a = "aa"; //C++ Much stricter , Double quotes represent strings 、 Single quotation marks indicate the character
Solution object_f;
bool b = object_f.isUnique(a);
cout << b << endl;
}
The method of bit operation takes less memory . First write the main content , Layer upon layer , Or you'll forget .
边栏推荐
- Go memory model
- 高手常用的15 种 SQL 优化
- Flink学习笔记(四)Flink运行时架构
- 分库分表
- 交叉熵损失函数
- 1. Qimage filling transparent brush; 2.path.addtext how to add line breaks
- 1. Closeable of qtablewidget, 2.pro/build_ pass、member,3.QString&&
- Wechat scans the QR code of the website, but only displays the link address, and cannot jump to the web page
- 程序员面试金典面试题 01.05. 一次编辑
- Parameter index out of range (1 &gt; number of parameters, which is 0).
猜你喜欢
Data storage partition -- range partition, hash partition, list partition, and indispensable part of performance tuning
Flink learning notes (IV) Flink runtime architecture
Strncpy() copy string (limited by length)
【YOLOv5实战4】基于YOLOv5的交通标志识别系统-模型测试与评估
Flink learning notes (V) datastream API
Kindling the Darkness: A Practical Low-light Image Enhancer
Leetcode 105. constructing binary trees from preorder and inorder traversal sequences
STM32+ESP8266+MQTT协议连接OneNet物联网平台
PTA basic question 7-23 currency conversion (20 points) (true)
程序员面试金典面试题 01.04. 回文排列
随机推荐
Exercise 7-4 find out the elements that are not common to two arrays (C language)
Three ways to restrict IP access between micro services
交叉熵损失函数
C语言 static和extern知识点
Code -
Upgrade win10sp1 to the latest version; Qt5.9.6 static compilation (network is valid)
mysql执行过程以及顺序
Shell脚本调试技术
fucking-algorithm
Log4j log configuration details
Flink学习笔记(五)DataStream API
Leetcode 114. expand binary tree into linked list
1. Lei Dian: transfer MySQL database to Oracle, 2.qt5.12.3 connect Oracle 12C database
MySQL statement execution order
1. MySQL null and in; What is 2.127.0.0.2?
Go memory model
The database is garbled. Do you want to find a solution?
Six dimensional space
卧式单面多轴钻孔组合机床动力滑台液压系统的设计
Summary of various materials - Network