You need not to check at a[0]. a[0]-0 can be greater than 100. if you have a charging station at 0 and at 150 you can travel. you have to check while returning.
Should I consider that her journey begins form 0 and ends at 1422? My algo is something like that: I am taking the input in an array & sort it. Then I am checking difference between index 0&1, 1&2, 2&3.... is<=200. Is it correct??
It seems that input will be given once for this problem. Whatever you can solve it while taking input. first read a char from input, if(ch==' '){ //check if str is the longest word or not. If it is copy it into another string lets say str1; //also check this if(!strcmp(str,"E-N-D")) break; } else if ...