Check if Word Equals Summation of Two Words LeetCode solution in C++
1class Solution {2public:3bool isSumEqual(string firstWord, string secondWord, string targetWord) {4int first = 0, second = 0, target = 0;5for (int i = 0; i < firstWord.size(); i++) first = first * 10 + (firstWord[i] - 'a');67for (int i = 0; i < secondWord.size(); i++) second = second * 10 + (secondWord[i] - 'a');89for (int i = 0; i < targetWord.size(); i++) target = target * 10 + (targetWord[i] - 'a');1011return first + second == target;12}13};