This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int INF = 1e9+7; | |
static int cache[100001][2]; | |
static int run(int idx, int taken, vector<int>& nums) { | |
const int N = size(nums); | |
if (idx == N and taken == 1) return -INF; | |
if (idx == N) return 0; | |
if (cache[idx][taken] != -1) return cache[idx][taken]; | |
if (taken) return cache[idx][taken] = max( | |
run(idx + 1, 1, nums), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def maxProfit(self, nums: List[int]) -> int: | |
return sol8(nums) | |
def sol1(nums): | |
N = len(nums) | |
INF = 10**10 | |
@cache | |
def run(idx, taken): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import functools | |
COMMANDS = { | |
"clone": lambda: print("clone processed"), | |
"init": lambda: print("init processed"), | |
"add": lambda: print("add processed"), | |
"mv": lambda: print("mv processed"), | |
"restore": lambda: print("restore processed"), | |
"rm": lambda: print("rm processed"), |
OlderNewer