This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def addStrings(self, num1: str, num2: str) -> str: | |
# Initialize pointers for num1 and num2 | |
i, j = len(num1) - 1, len(num2) - 1 | |
carry = 0 | |
result = [] | |
# Loop through both strings from end to start | |
while i >= 0 or j >= 0 or carry: | |
digit1 = ord(num1[i]) - ord('0') if i >= 0 else 0 |