السلام عليكم
ده مسائل من LeetCode
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
وده الحل بتاعي
# Interview Google
class Solution:
def towSum(self,nums,target):
for i in range(len(nums)):
for j in range(i+1,len(nums)):
if nums[i] + nums[j] == target:
print(f"{nums[i]} + {nums[j]} = {target}")
return 1
print("Not Found")
return 0
num = Solution()
num.towSum([2,7,11,15],9)
الكود ده بيشتغل عادي علي Vscode ولكن علي LeetCode مش بيشتغل وبيظهار الخظاء ده
SyntaxError: invalid syntax
^
print(f"{nums[i]} + {nums[j]} = {target}")
Line 7 (Solution.py)