Find the first non repeating character in a string | String Algorithms

  Рет қаралды 23,885

CodeWithRajRanjan

CodeWithRajRanjan

5 жыл бұрын

In this video we will find the first non repeating character in a string. we will use a hash-map to store the frequency of every character in the string and then we will try to traverse the string from front and check the character whose frequency is 1. The first character that which has a frequency of 1 is the the first non repeating character

Пікірлер: 8
@raghuvarun5941
@raghuvarun5941 4 жыл бұрын
Bro, can you please explain some important programs given in w3resource Java exercises...the way you are explaining is exceptional
@pratapjavasingh3239
@pratapjavasingh3239 3 жыл бұрын
Boss upload the video regarding the ds and algorithms that's the enough for product based company
@muaazkhan6156
@muaazkhan6156 Ай бұрын
Additional Knowledge: 1. while printing remove break; from last if then u will get all the unique character in String. 2. if u use > 1 instead of == the u will get all the dublicated character.
@asmitabarman7404
@asmitabarman7404 4 жыл бұрын
if i write if(currentFreq!=1) will i get the first repeating charechter?
@AMANSINGH-yv4vv
@AMANSINGH-yv4vv 3 жыл бұрын
same question for me
@NaryVip
@NaryVip 3 жыл бұрын
Better keep that condition as >1 , So you will get the first repeating char.
@sai3327
@sai3327 4 жыл бұрын
Can you clarify what is the advantage of your way to solving the issue? VS this public static void main(String[] args) { char c = getFirstNonRepeatedChar("aabbddeeff"); System.out.println("Non Repeated Character="+c); } public static char getFirstNonRepeatedChar(String str) { Map countMap = new LinkedHashMap(str.length()); for (char ch : str.toCharArray()) { countMap.put(ch, countMap.containsKey(ch) ? countMap.get(ch)+1:1); } for (Entry entry : countMap.entrySet()) { if (entry.getValue()==1) { //return entry.getKey(); break; } } throw new RuntimeException("didnt find any non repeated Character");
First non repeating character in a stream | Leetcode #387
11:23
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 18 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 7 МЛН
Despicable Me Fart Blaster
00:51
_vector_
Рет қаралды 24 МЛН
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 17 МЛН
I solved 541 Leetcode problems. But you need only 150.
7:42
Sahil & Sarra
Рет қаралды 2,3 МЛН
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 408 М.
The Truth About Learning Python in 2024
9:38
Internet Made Coder
Рет қаралды 156 М.
Whiteboard Coding Interviews: 6 Steps to Solve Any Problem
15:18
Fullstack Academy
Рет қаралды 362 М.
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 18 МЛН