Skip to content

Commit f83ba4f

Browse files
authored
Create Check if Word Equals Summation of Two Words.java
1 parent 40e677e commit f83ba4f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public boolean isSumEqual(String firstWord, String secondWord, String targetWord) {
3+
return getNumericalValue(firstWord) + getNumericalValue(secondWord) == getNumericalValue(targetWord);
4+
}
5+
6+
private int getNumericalValue(String s) {
7+
int value = 0;
8+
for (char c : s.toCharArray()) {
9+
value = value * 10 + (c - 'a');
10+
}
11+
return value;
12+
}
13+
}

0 commit comments

Comments
 (0)