当前位置:网站首页>Sword finger offer 50. the first character that appears only once
Sword finger offer 50. the first character that appears only once
2022-07-29 08:34:00 【ThE wAlkIng D】
Title Description
Problem analysis
- Use arrays to store , Different character elements are stored in different positions , Add one to the repeated character elements
- The last part for Loop traversal operation pair subtraction a Value of character , Judge whether the value on a bit is one , If it is one, it means that the character only appears once
Code instance
class Solution {
public char firstUniqChar(String s) {
int[] count = new int[26];
for(int i = 0;i < arr.length();i++){
char c = s.charAt(i);
count[c - 'a']++;
}
for(int i = 0;i < arr.length();i++){
char c = s.chaAt(i);
if(count[c - 'a'] == 1){
return c;
}
}
return ' ';
}
}
边栏推荐
- Is the sub database and sub table really suitable for your system? Talk about how to select sub databases, sub tables and newsql
- The first week of postgraduate freshman training: deep learning and pytorch Foundation
- Cloud security daily 220712: the IBM integration bus integration solution has found a vulnerability in the execution of arbitrary code, which needs to be upgraded as soon as possible
- Pnpm install appears: err_ PNPM_ PEER_ DEP_ ISSUES Unmet peer dependencies
- Use disco diffusion to generate AI artwork in moment pool cloud
- Deep learning (1): prediction of bank customer loss
- New energy shared charging pile management and operation platform
- C language calculates the length of string
- Leetcode Hot 100 (brush question 9) (301/45/517/407/offer62/mst08.14/)
- Selenium actual combat case crawling JS encrypted data
猜你喜欢
PostgreSQL手动创建HikariDataSource解决报错Cannot commit when autoCommit is enabled
DC motor speed regulation system based on 51 single chip microcomputer (use of L298)
7.3-function-templates
AI application lesson 1: C language Alipay face brushing login
110道 MySQL面试题及答案 (持续更新)
Proteus simulation based on msp430f2491 (realize water lamp)
PostgreSQL manually creates hikaridatasource to solve the error cannot commit when autocommit is enabled
Hal library learning notes - 8 concept of serial communication
Virtual augmentation and reality Part 2 (I'm a Firebird)
Multifunctional signal generator based on AD9850
随机推荐
Clickhouse learning (II) Clickhouse stand-alone installation
node:文件写入数据(readFile、writeFile),覆盖与增量两种模式
AES bidirectional encryption and decryption tool
Use disco diffusion to generate AI artwork in moment pool cloud
Temperature acquisition and control system based on WiFi
Hal learning notes - Advanced timer of 7 timer
leetcode hot 100(刷题篇9)(301/45/517/407/offer62/MST08.14/)
RPC和REST
Personal study notes
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
Osgsimplegl3 example analysis
Cluster usage specification
Chrony 时间同步
Is the sub database and sub table really suitable for your system? Talk about how to select sub databases, sub tables and newsql
Stm8s003 domestic substitute for dp32g003 32-bit microcontroller chip
ML.NET相关资源整理
Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
Collation of ml.net related resources
Compatible with cc1101/cmt2300-dp4301 sub-1g wireless transceiver chip
PostgreSQL manually creates hikaridatasource to solve the error cannot commit when autocommit is enabled