Skip to content

Instantly share code, notes, and snippets.

View Kavin-Sakthivel369's full-sized avatar

Kavin-Sakthivel369

View GitHub Profile
@Kavin-Sakthivel369
Kavin-Sakthivel369 / Add Strings
Last active May 19, 2025 04:54
LeetCode_Problems
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