Skip to content

Latest commit

 

History

History
28 lines (28 loc) · 1.76 KB

notes.org

File metadata and controls

28 lines (28 loc) · 1.76 KB

to find the total sign in list of arrays in the problem leet sign of product array this is used instead of storing num of neg values

if n < 0:
    n = -n

dynamic programming

it can also be thought of as a procedural way to build solutions to bigger problems from simpler problems

for example coin change

we consider solutions to all possible combinations of problems this way

example coin change problem

even though we don’t want number of ways to form smaller sums, we do it as it is part of larget sum

a systematic way to visit all possible combinations so we don’t miss out any

a way to organize data of smaller problems so that we can access it easiy

we know the solutions to base case and composite cases are calculated from base case

one of a kind problems

we can find all ways of climbing by simple formula ways(curr + 1, target) + ways(curr + 2, target)

Easy to make recursive program with loop using stack

see invert_binary_tree2

I liked the way I did number of changes between app and website

Became I used prev = None the first comparison gets the changes value to 1

initial I started changes=-1 but it is not correct

I was particularly facing issue with comparing last element of one with rest of the other array

it all solved because I used prev = None and changes = 0

if the parts allowed are only down and right we need not worry about cycles

different startegies

we can append another number at end to avoid special case checking

like adding negative number for maximum contiguous array