当前位置:网站首页>HJ delete the character with the least number of occurrences in the string
HJ delete the character with the least number of occurrences in the string
2022-06-28 07:37:00 【Courageous steak】
Knowledge point : character string 、 Hash
describe
Delete the least frequent character in the string , If there are multiple characters with the least number of occurrences , Then delete the characters that appear the least . Output the string after deleting these words , The other characters in the string remain in the same order .
Data range : The length of the input string meets the requirements 1≤n≤20, Ensure that only lowercase letters appear in the input string
Input description :
String contains only lowercase letters , Illegal input is not considered , The length of the input string is less than or equal to 20 Bytes .
Output description :
Delete the string after the least frequent character in the string .
Example 1
Input :aabcddd
Output :aaddd
Cattle guest HJ Python
# The elapsed time 29ms Take up memory 4532KB
while True:
try:
# Input
str = input()
dic, res = {
}, ""
# Enter each letter into the dictionary
for i in str:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
# Get in the dictionary Minimum value
min = min(dic.values())
# Put the minimum Replace empty
for i in str:
if dic[i] == min:
str = str.replace(i, "")
print(str)
except:
break
Link to the original text :
https://www.920vip.net/article/177
边栏推荐
- Sentinel mechanism of redis cluster
- kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑
- kubelet垃圾(退出的容器和未使用的镜像)回收源码分析
- Open62541 import nodeset file directly
- Devtools implementation principle and performance analysis practice
- kubernetes删除pod的流程的源码简析
- 逆波兰表达式求值<难度系数>
- Introduction and several months' experience of extending the solution thanos of Prometheus
- Makefile
- flex布局
猜你喜欢

goland IDE和delve调试位于kubernetes集群中的go程序

GoLand IDE and delve debug Go programs in kubernetes cluster

kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑

Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)

PLC -- Notes

分析 NFT 项目的 5 个指标

Leetcode+ 66 - 70 high precision, two sub topics

Kubernetes cluster lossless upgrade practice

The practice of traffic and data isolation in vivo Reviews

Kubernetes理论基础
随机推荐
Llvm and clang
Ice, protobuf, thrift -- Notes
Sword finger offer II 091 Paint the house
R language Kolmogorov Smirnov tests whether the two samples follow the same distribution.
HJ进制转换
Mysql57 zip file installation
Spark 离线开发框架设计与实现
R 语言 ggmap 可视化集群
Tencent continued to lay off staff in the second half of the year, and all business groups reduced by at least 10%. What do you think of this? Followers
Rediscluster cluster mode capacity expansion node
R 语言 Kolmogorov-Smirnov 检验 2 个样本是否遵循相同的分布。
kubelet驱逐机制的源码分析
Jetpack - defects of livedata component and Countermeasures
HJ明明的随机数
Devtools implementation principle and performance analysis practice
goland IDE和delve调试位于kubernetes集群中的go程序
[ thanos源码分析系列 ]thanos query组件源码简析
7-2 Finnish wooden chess structure Sorting
es6箭头函数中return的用法
What should I do if the version is incompatible with the jar package conflict?