当前位置:网站首页>Programmer interview golden code interview question 01.04. palindrome arrangement
Programmer interview golden code interview question 01.04. palindrome arrangement
2022-07-22 19:02:00 【yijun009】
class Solution {
public:
bool canPermutePalindrome(string s) {
int l = s.length();
if ((l==2)&&(s[0]!=s[1])) return false;
std::map<char,int> mymap;
for (int i =0;i<l;i++) mymap[s[i]]=0;
for (int i =0;i<l;i++) mymap[s[i]]++;
int count_odd=0;
for (std::map<char,int>::iterator it=mymap.begin(); it!=mymap.end(); ++it){
if (it->second%2==1) count_odd++;
}
if (count_odd>1) return false;
return true;
}
};
C++ Dictionaries map, When traversing the elements in the dictionary , Be careful if you want to use it key To traverse . The program written is not consistent with the idea .
边栏推荐
- mysql执行过程以及顺序
- MySQL master-slave replication
- Shell $*和[email protected]的区别
- 程序员面试金典面试题 01.01. 判定字符是否唯一
- Shell脚本调试技术
- JSON序列化对象时,如何返回有空值的带属性名称json字符串?
- 卧式单面多轴钻孔组合机床动力滑台液压系统的设计
- Interrogation aléatoire de n données dans diverses bases de données
- 【YOLOv5实战4】基于YOLOv5的交通标志识别系统-模型测试与评估
- After the project is started, the mapper XML file is loaded circularly
猜你喜欢
Design of hydraulic system for power slide of horizontal single side multi axis drilling combined machine tool
JUC synchronizer
高手常用的15 种 SQL 优化
Flink learning notes (III) Flink installation and deployment
Flink学习笔记(四)Flink运行时架构
Interrogation aléatoire de n données dans diverses bases de données
交叉熵损失函数
6-2-depth first search underground maze exploration (30 points)
Recursively find the partial sum of simple alternating power series (15 points)
PTA basic question 7-23 currency conversion (20 points) (true)
随机推荐
Kindling the Darkness: A Practical Low-light Image Enhancer
Flink learning notes (IV) Flink runtime architecture
webFlux 中使用 openFeign 实现远程调用遇到的问题
1. Qimage filling transparent brush; 2.path.addtext how to add line breaks
Bull column - blog summary
STM32+ESP8266+MQTT协议连接OneNet物联网平台
PTA 基础题7-28猴子选大王(简单方法)
Parameter index out of range (1 &gt; number of parameters, which is 0).
Go language learning: go language journey - exercise questions and reference answers
[QT source code reuse] simulate the pop-up mode of qcompleter
Sorting of in-depth learning materials
Leetcode: 184. the highest paid employee in the Department
LeetCode 654. 最大二叉树
Flink学习笔记(七)处理函数
Cross entropy loss function
图像质量评价
numpy 求矩阵非零元素的均值
Interrogation aléatoire de n données dans diverses bases de données
Problems encountered in using openfeign to realize remote call in Webflux
Randomly query n pieces of data in various databases