Hello! Welcome to the Python for ACSL course. I am Henry, and will be this summer's TA. Chris will be this summer's instructor. We're looking forward to teaching you everything you need to know to ace this year's ACSL contests. Every week, I will post homework, as well as any lesson plan/slideshows. If you have any questions, feel free to contact me or Chris.
Chris (Instructor) : chris13888@gmail.com
Henry (TA) : henry.zheng.2006@gmail.com
Chris and I both will be using repl.it or leetcode.com for coding future homework projects, as it is easier to share and collaborate on. If you already have an account, use your existing one. If not, we recommend signing up for it at replit.com/signup and leetcode.com/accounts/signup/. Make sure to set the coding language to Python3.
LESSON PLAN
Slideshow - https://docs.google.com/presentation/d/1ERXT8L6JU1b5IvCeAj9SQSAepqzb8sKkAm4cMbG-bRU/edit?usp=sharing
Homework - https://leetcode.com/problems/two-sum/
Solution - https://www.code-recipe.com/post/two-sum
class Solution:
def twoSum(self, nums, target):
for i in range(len(nums))
for j in range(i+1, len(nums))
if nums[i] + nums[j] == target
return[i, j]
class Solution(object):
def twoSum(self, nums, target):
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[j] == target - nums[i]:
return [i, j]
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for frontIndex in range(0, len(nums)):
for nextIndex in range(frontIndex+1, len(nums)):
if nums[frontIndex] + nums[nextIndex] == target:
return frontIndex, nextIndex
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[i] + nums[j] == target:
return i, j
Do I answer here?