Added C++ solution which is exact copy of C solution