Learn from Leaders, Learn from ABC. Watch our latest technical videos in your language: For Hindi:- bit.ly/2TRuGVP For Kannada:- bit.ly/31NH63M For Telugu:- bit.ly/2MuYRRP For Tamil:- bit.ly/2Num5Hz
@fanalu87884 жыл бұрын
I am just a beginner, just following your series help me understand a lot more than just reading the answers. Thanks a lot.
@ashishsuman70794 жыл бұрын
what if 2 characters occurs highest number of times in the string ?
@rajatbatra22564 жыл бұрын
Thanks for such a awesome series sir.. it's really helpful...you are doing a great job by keeping education and.technology side by side..this is one.of.the best tutorial on KZbin.
@ABCforTechnologyTraining4 жыл бұрын
Thanks for acknowledging our efforts, Rajat! Edutainment is the new form of education to both educate as well as amuse. Keep watching, Keep learning!
@sibisidharth49334 жыл бұрын
for iteration we have to use entry set function for(Map.Entry data:lhmap.entrySet())
@ankitpandit59984 жыл бұрын
Good way to teach
@MdAzad-hb7vc4 жыл бұрын
Fabulous way of teaching!! But this code leaves an edge-case.. as in, it would not be able to print multiple max occurring characters.
@MdAzad-hb7vc4 жыл бұрын
Settmap = wMap.entrySet(); int counter =0; for ( Map.Entry data :tmap){ if (data.getValue() > counter ) { counter = data.getValue(); } } // iterates through the map again, to find key/keys with the counterValue. for (Map.Entry data2 : tmap){ if (data2.getValue() == counter) System.out.print(data2.getKey() ); }
@MdAzad-hb7vc4 жыл бұрын
Well, there is a much easier approach than what i just wrote above! Settmap = wMap.entrySet(); int counter =0; char val = ' '; for ( Map.Entry data :tmap){ if (data.getValue() >= counter ) { counter = data.getValue(); val = data.getKey(); System.out.print(val); } }
@ankitshrivastava17724 жыл бұрын
Excellent.
@ABCforTechnologyTraining4 жыл бұрын
Thanks for listening. Happy learning!
@shashikiranb42304 жыл бұрын
U ARE AWESOME ...
@business1875 жыл бұрын
CAN U plzzz MAKE TUTORIALS ALGORITHM?? Plzzzzzzzzzzz
@rajatbatra22564 жыл бұрын
What if 2 characters are repeating maximum.no.of.time???
@nimasherpa60935 жыл бұрын
What would have if more than single character have it's maximum value The same instructor of code is not giving the desire output
@srinivaskatam9984 жыл бұрын
Same doubt for me bro .....if any knows, please explain....
@jhansiranikavali27094 жыл бұрын
sir what if we have more than most repeating characters? also how to find the least repeating characters if the string contains more then one characters????
@prachigarg14005 жыл бұрын
Sir, how can we find the second highest occurring character in a string ??
@jamesbonding39884 жыл бұрын
get the top 1 .. then remove the top 1 or filter .. run again your algo .. then you got the 2nd one :) or you do a sort by value place a rank
@abdullahbaabbad8854 жыл бұрын
This is another logic Since we put the variables in the map by making use of newval variable it means newval variable contains the maximum value in which the character has been occuring. Hence we will just compare it with other values and print it the code is: public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter your String"); String s = sc.nextLine(); s = s.toLowerCase(); char c[] = s.toCharArray(); int newval = 0; Map map = new HashMap(); for (int i = 0; i < s.length(); i++) { if (map.containsKey(c[i]) == false) { map.put(c[i], 1); } else { int oldval = map.get(c[i]); newval = oldval + 1; map.put(c[i], newval); } } Set hmap = map.entrySet(); for (Map.Entry data : hmap) { if (data.getValue() == newval) { System.out.print(data.getKey()); System.out.println(data.getValue()); } } } }
@DhanaLakshmi-lw7xo4 жыл бұрын
no its not working check with thiss input aaaahhhhhhhhhjjjj
@maksaini75155 жыл бұрын
char maxkey =' '; giving error how to resolve it.
@ABCforTechnologyTraining5 жыл бұрын
Please share your complete program code here. We'll fix the errors for you.