...
| Code Block |
|---|
def is_palindrome(word):
j = len(word)-1
i =0
while i<j and word[i].lower()==word[j].lower():
i+=1
j-=1
return (i>=j)
print(is_palindrome('Deleveled')) |
Two some - return indices of the two numbers such that they add up to a specific target
| Info |
|---|
Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, |
| Code Block |
|---|
def twoSum(self, nums, target):
seen = {}
for i, v in enumerate(nums):
remaining = target - v
if remaining in seen:
return [seen[remaining], i]
seen[v] = i
return [] |