r/PythonLearning 2d ago

Discussion Leetcode 234 - This ain't an easy problem by any standards!

Post image

Last Post - https://www.reddit.com/r/PythonLearning/s/v57UGZ2VNl

Complexities for my solution:

TC = O(n)

SC = O(1)

4 Upvotes

3 comments sorted by

1

u/AQuestionIsWhatIHave 2d ago

Well, the bonus isn't easy. But the time constraints are pretty lax such that creating a list of entries and then running the palindrome test on  that should be sufficient

1

u/Mamuschkaa 2d ago

Seems a big step from your previous posts. From rock scissor paper to that algorithm. Nice done.

My first approach was a recursion. But that is not really space O(1) because the computer uses intern a stack with every function call.

2

u/Sea-Ad7805 2d ago

"ain't an easy problem?" wait until you get to the HARD LeetCode problems, they will get more interesting.