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

3

u/memeaste Oct 05 '26

That's good. I had 2 coding assessments for a job I applied for, 1 was tricky while the other one was weirdly simple. Both were entry level, which is weird.

2

u/RandomPantsAppear Oct 05 '26

Yeah most aren’t super hard unless it’s FAANG. I’m actually shit at leetcode and have to specifically practice it, but mostly because not much of it is relevant to my actual job (20 years YOE).

People who went to university for it tend to be better at it because it’s not so different from a lot of the questions they get there.

1

u/memeaste Oct 05 '26

I went to college for CS, so not directly for Software Dev/Eng, which I sort of regret. But nothing I can do now except make the most of what I can do and improve on my skills, which is what I'm trying to do. Software administration isn't bad, but I'd like to see what else I can do.

2

u/RandomPantsAppear Oct 05 '26

😅 in my day those were the same, not sure if that has changed. If so, it should apply to CS also unless the courses have wildly changed.

2

u/memeaste Oct 05 '26

Maybe it's the lack of experience in comparison between the two of us. I work in IT at a bank and I just make sure the core software throughout works, in vague terms. I do do automation with Python, writing reports with SQL, but the vague term is what I tell people. Feels more of an administration position as opposed to actively writing code and creating software. Our software is third party, so it's not like we developed it in-house. I've been here since 2024

1

u/Expensive-Bear-1376 Oct 05 '26

Can you tell what the tricky one was?

1

u/memeaste Oct 05 '26 edited Oct 06 '26

I don’t remember it 1:1, but it something where I had to iterate a list by 3 or n where n is a number that ends in 3 and is a prime number to get the honest highestpossible value

1

u/Expensive-Bear-1376 Oct 06 '26

Ok I can't make sense of that, I don't even know what an "honest" value is.

1

u/memeaste Oct 06 '26

Oh shoot, I didn't notice there was a typo. Looking for the highest possible value. Given the following list, I'd have to find the highest possible value while moving by an index of 1, 3, or a prime number ending in 3. Like I said, I don't recall it 100%, but this is what I remember. Not all lists were visible to test, this is an example. The highest value with the rules would be 16.

5 -> 6 (list[1] -> list[2])

6 -> 5 (list[2 + 3])

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

1

u/Expensive-Bear-1376 Oct 06 '26

Was there a size limit for the list?

2

u/memeaste Oct 06 '26

Not in the instructions, but I ran len(list) on their test cases and got back some at 1000. Only 2 test cases were actually visible to see, and those were at a size of 5-8 elements

1

u/Expensive-Bear-1376 Oct 06 '26

And are we allowed to start and end at any indices? (Otherwise I don't see why in your example we're allowed to start on index 1.)

What's tricky about it? Have you solved it by now? I have some solutions in mind myself.

2

u/memeaste Oct 06 '26

I believe you were to start at 1 all of the time, but I don’t recall the conditions for ending. I ended up running out of time, as it took me a little while to figure out what it was asking. The question made up a story like it was someone traveling and each town that they visited, they either spend or gained money. They could only move adjacent (+1), 3 towns (+3), or the prime number ending in 3 towns over.

I had some ideas but I ran out of time as I got to the part to calculate and figure out which would yield the biggest value. I wish I took a photo of it so I could do it exactly how they wanted it. I knew what I needed to do, but admittedly, I didn’t know of a great way to do it besides possibly a long loop. And even that, I wasn’t sure. I also did want to look at the second question, which would’ve taken me longer to read, so I gave myself 15-20m at the end to look at it

1

u/Expensive-Bear-1376 Oct 06 '26

Ah dang, having to start at 1 is annoying. And unexpected, since index 0 is then unreachable and thus pointless. I implemented my solutions now and they're cute, but they start anywhere. Going to bed, might adapt them tomorrow.

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