0
Time exceeded limit in c
I tried to run the code but it said time exceeded limit. What do i have to change? a.dat file contain = 0x01 0x02 0x03 0x41 0x42 0x43 0x0D 0x0A 0xFF 0xFE 0xFD 0x01 0x02 0x03 0x80 0x7F 0x0D 0x0A ######### Example1: Input = 01 Output = 2 (Because there are 2 0x01 in the file) Example2: Input = FF Output = 1 (Because there is 1 0xFF in the file) The code: https://code.sololearn.com/cI0ZmcK1wPpb/?ref=app
1 Answer
0
You could cut out some processing time and save memory by first getting console input (before reading the file) and then comparing the value while reading the file. Then there is no need to store all of the file into an array. Just check each value as you read it.