r/learnpython • • Oct 05 '26

Is Leetcode a good way to continue practicing/learning Python?

I'm not entry, but I'd like to continue becoming stronger in my skills.

29 Upvotes

37 comments sorted by

View all comments

Show parent comment

1

u/Expensive-Bear-1376 Oct 07 '26

Ok I adapted to starting at index 1 (and ending at any index). I don't want to spoil it, so here's just a "shadow" of my code, with most non-space characters replaced with #:

a = [0, 5, 6, -10, -20, 5]

##### # ##
### # ## ######## ########
    ## # ## # ## ## # ## ## # ### ##### # # ### # ## ######## #####
        ###############
    ##### ## ########### ### # ## ######

print(####)

That prints 16.

And here's a larger input in case you or someone else wants to do it as well:

a = [30, -12, 22, -56, -59, -27, 45, 66, -56, 91, -1, -28, 43, 8, -71, 81, -9, 40, 71, 22, -3, -84, -65, 21, -43, -34, 3, 71, 41, 65, -94, 96, 99, -41, 75, -42, -23, 52, -12, 18, -58, 86, -99, -26, -73, -24, -90, -70, -64, 50, -14, 91, -24, 16, 81, -12, -97, 51, 60, 46, -26, -19, -47, 52, 20, 70, 37, -20, 35, 15, 41, 46, -32, -85, 24, 46, -100, -10, 8, -38, 4, -61, -70, 19, -27, -38, -55, -3, -2, 9, -84, -65, -19, -98, -25, 33, -10, 34, -98, 99]

Result: 1558