Ad
  • Default User Avatar

    In C, this is a very common practice and should be very obvious so I would say it is a best practice. The point you're getting at is good,t though. It's just doing a null check on this string in this way is idiomatic C.

  • Default User Avatar

    Not to take away from the solution but this and most other solutions I see using strcmp and going through all 55 possibilities for every token. A different approach is to simply build a prefix tree and you will not need additional loops. Also, each code is fairly small, so with a tree, we do not travel very far in the tree for each symbol.