Skip to content

Instantly share code, notes, and snippets.

View idfumg's full-sized avatar

Artem Pushkin idfumg

View GitHub Profile
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),
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):
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"),