Most frequent bytes

  • 20
  • Locked
Enter a file name from the console. Find the byte or bytes with the maximum number of repetitions. Display them on the screen, separated by spaces. Close the IO stream.
You can't complete this task, because you're not signed in.
Comments (17)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Олег Байбула
Level 32 , Ukraine
16 February, 11:40
Weird solution. You should've used Map.
Adam Odoj
Level 22 , Poland
28 October 2022, 16:24
Why in correct solution they decided to create array with 256 element for FileInputStream? It looks loke that: " int[] byteCountArray = new int[256]; " But you don´t know what is in the file so why you limit to number of ASCII control characters ? I probably didn´t understand something...
Level 22 , Iasi, Romania
28 January 2022, 10:47
for months i postponed studying maps because looked to difficult to remember. 2 days ago after a long time i decide it to go back on chapter 8 and read about them. now when i saw this task i immediately said to myself "this is easy to do with a Map", and took me less than 10 minutes to solve this. i really liked this one.
Justin Smith
Level 39 , Greenfield, USA, United States
28 September 2021, 13:58
Wow, got it in the first try with no test file. Did not expect that!
Level 20 , Poland
24 September 2021, 20:14
I was using ArrayList, SetList, HashMap to solve this task. It takes me 40 minutes. but I didn't understand what they excatly want from me at the begining.
Level 24 , Wittenberg, Germany
6 June 2021, 13:28
task1803 () CLARIFICATION: the task description may seem a bit vague but I just got my code to pass by taking the text literally (i.e. reporting a space-separated string of numbers corresponding to the octet values that occur most often in the input). 'octet' stands for 'unsigned byte', i.e. values between 0 and 255.
Gellert Varga
Level 23 , Szekesfehervar, Hungary
25 May 2021, 20:26
Don't use static variables!!!
Level 41 , Madrid, Spain
23 December 2020, 14:22
Don't use readAllBytes() method to solve this one. If you do so your program won't compile.
Level 25 , Bexleyheath, United Kingdom
4 October 2020, 09:36
Yup. Hard. Took ages.
Level 23 , Columbia, United States
18 August 2020, 18:31
I had to use two nested for loops (total of four for loops) to get the most occurring bytes to display . Put everything in an arraylist first. Didn't think it'd be so difficult. Took hours.