Skip to content

Instantly share code, notes, and snippets.

@fado
Forked from resetter/MinOccurance2.java
Last active August 29, 2015 14:04
Show Gist options
  • Save fado/94f32f643cca13f14fef to your computer and use it in GitHub Desktop.
Save fado/94f32f643cca13f14fef to your computer and use it in GitHub Desktop.
import java.io.*;
public class MinOccurance2 {
public static void main (String[] args) throws IOException {
int[] occur = new int[256];
int current = 0;
RandomAccessFile file = new RandomAccessFile("test.txt", "r");
long length = file.length();
for ( int i = 0; i < length; i++) {
current = file.read();
int highNibble = Current >>> 4 ;
int lowNibble = Current & 0x0f;
occur[highNibble]++;
occur[lowNibble]++;
}
for ( int k = 0; k < 4; k++) {
System.out.println(k + " " + occur[k]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment