const firstNonRepeatingCharacter = (str) => { let count = str.split('').reduce((obj, char) => { obj[char] = ++obj[char] || 1; return obj; }, {}); for (const key in count) { if (count[key] === 1) { return key; } } return null; };
- const firstNonRepeatingCharacter = (str) => {
let chars = [], counts = [];for(const char of str) {let index = chars.indexOf(char);if(index < 0) {index = counts.length;chars.push(char);counts.push(0);}counts[index]++;}for(let index = 0; index < chars.length; index++) {if(counts[index] === 1) {return chars[index];- let count = str.split('').reduce((obj, char) => {
- obj[char] = ++obj[char] || 1;
- return obj;
- }, {});
- for (const key in count) {
- if (count[key] === 1) {
- return key;
- }
- }
- return null;
- };
const firstNonRepeatingCharacter = (str) => { let count = str.split('').reduce((obj, char) => { obj[char] = ++obj[char] || 1; return obj; }, {}); for (const key in count) { if (count[key] === 1) { return key; } } return null; };
- const firstNonRepeatingCharacter = (str) => {
let chars = [], counts = [];for(const char of str) {let index = chars.indexOf(char);if(index < 0) {index = counts.length;chars.push(char);counts.push(0);}counts[index]++;}for(let index = 0; index < chars.length; index++) {if(counts[index] === 1) {return chars[index];- let count = str.split('').reduce((obj, char) => {
- obj[char] = ++obj[char] || 1;
- return obj;
- }, {});
- for (const key in count) {
- if (count[key] === 1) {
- return key;
- }
- }
- return null;
- };