Check if Word Equals Summation of Two Words Problem
Check if Word Equals Summation of Two Words Problem — ExecCode Easy DSA Practice
Solve the Check if Word Equals Summation of Two Words problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive. Your task is to compute the required answer and return true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord , or false otherwise. The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.). The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer. - For example, if s = "acb", we concatenate each letter's letter value, resulting in "021".
Examples
Input {"firstWord": "acb", "secondWord": "cba", "targetWord": "cdb"}; Output True. Input {"firstWord": "aaa", "secondWord": "a", "targetWord": "aab"}; Output False
Constraints
1 <= firstWord.length,secondWord.length,targetWord.length <= 8 firstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive.
Practice Check if Word Equals Summation of Two Words free on ExecCode. Browse DSA problems, topic map, and placement guides.