I have anothe theory about the problem. I think he has a stream of binary data and wants to count the number of ones. So if the input of the program is
00110101011
then the output is 6 I believe
).
The problem is that the size of the data is very big. Now, I see 2 possibilities:
1) Either the data is in binary, so if you look into the file you will see any kind of symbols, each of them representing a byte and therefore 8 bits. In this case the problem consists of adding about 300.000 bytes (the size of the file about 300.000, if I recall correctly), which I think fits in a long. I mean: the worst case is that all the bits are 1 and in this case the addition will be 300.000x8. Of course if the file becomes bigger and bigger there will be a moment when built in integers datatypes won't be enough, but we need a VERY big file for that, isn't it? we need that 300.000x8>capacity of a long = 2.147.483.647. Therefore a file of about 250Mb, a lot more than 300Kb anyway.
2) Either the data is in ASCII, so if you look inside there are only 0's and 1's, and in this case the maximum number of 1's is 300.000.
In any case you don't need to store the full string into memory, so that's why I'm not sure about my interpretation of the problem, so I would like to ask: Is the order of the data important?? Will the output be different if you put the information "up-side-down"?