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.
Most frequent bytes
- 20
Locked
Comments (17)
- Popular
- New
- Old
You must be signed in to leave a comment
Олег БайбулаExpert
16 February, 11:40
Weird solution. You should've used Map.
0
Adam Odoj
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...
0
Alaskian7134
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.
0
Justin Smith
28 September 2021, 13:58
Wow, got it in the first try with no test file. Did not expect that!
+1
Vitalina
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.
0
DarthGizka
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.
0
Gellert Varga
25 May 2021, 20:26
Don't use static variables!!!
0
Isma
23 December 2020, 14:22
Don't use readAllBytes() method to solve this one. If you do so your program won't compile.
+1
Switch/Cypher
4 October 2020, 09:36
Yup. Hard. Took ages.
0
Petros
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.
0