Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions buy_and_sell_stocks/buy-sell-stocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import List


class Solution:
def maxProfit(self, prices: List[int]) -> int:
lowest_price = prices[0]
max_profit = 0
for price in prices:
if price < lowest_price:
lowest_price = price
elif price - lowest_price > max_profit:
max_profit = price - lowest_price
return max_profit
12 changes: 12 additions & 0 deletions two-sum/two-sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import List


class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
answer: List[int] = []
for i in range(len(nums)):
for j in range(len(nums)):
if nums[i] + nums[j] == target and i != j:
answer.append(i)
answer.append(j)
return answer