Interview Code Snippets: Part 1
Interviews in the field of programming are all very similar, usually involving a whiteboard and an algorithm. Sometimes these questions are so incredibly simple, yet for whatever reason you can’t craft an answer on the spot. I’m going to start a series on some code snippets that are common to see in interview situations. All this code is in C++, for no other reason than it happens to be what I’m playing with the most right now.
The first in this series is one that comes easily to most, but I figured I’d start with something simple.
Problem:
Write a function to determine if a string starts with an upper case letter between A and Z.
Solution:
bool starts_with_uppercase(std::string suspect) { if(suspect[0] > 'A' && suspect[0] < 'Z') return true; else return false; }
More soon.