r/learnpython • • Jul 14 '26

Logic building and pattern recognition in python

I can't see any solution to an easy beginner question in my mind please somebody help every tip will help me a lot you guys helped me a lot in my previous problem kindly help me 🙏😭

0 Upvotes

17 comments sorted by

View all comments

4

u/Puzzlehead_Lemon Jul 14 '26

Could you give us an example of what's causing you issues? We need a bit more information to be able to help.

-5

u/DealerStill4006 Jul 14 '26

Like I learn for loop or while loop i understand it from the video but I don't know when and where to apply it like the very basic question #1 on leetcode two sum😢

3

u/LayotFctor Jul 14 '26

Leetcode is not basic btw. You don't do leetcode until you've studies DSA. It's just going to demoralise you otherwise.

1

u/DealerStill4006 Jul 14 '26

So what should I do??

1

u/Puzzlehead_Lemon Jul 14 '26

Check out some beginner projects, or if you want something a bit guided there's several sites that have a course to help with learning it. The one I used was Boot.dev, you can access their entire course for free, but if you want the bells and whistles with it you need to pay.

LearnPython.org and there's a load of YouTube videos as well that can help.

2

u/DealerStill4006 Jul 14 '26

Ok thanks I will definitely try🫶❤️

2

u/[deleted] Jul 14 '26

[removed] — view removed comment

1

u/DealerStill4006 Jul 14 '26

Ok thanks 🫶❤️

1

u/Puzzlehead_Lemon Jul 14 '26

If you have a video card with a half-decent amount of VRAM, I'd recommend running a local agent and try to use it like a teacher you can ask questions.

If you're doing Google searches for help on a problem, you'll frequently end up on StackOverflow, and the answers can get a bit hard to follow until you have enough practice reading what they're saying. It's also very easy to end up searching for the wrong answer because you didn't know about something like enumeration.

2

u/[deleted] Jul 14 '26

[removed] — view removed comment

1

u/DealerStill4006 Jul 14 '26

Yes sir the kind of answer I want like how you get to it from the beginning thanks a lot🫶❤️

1

u/chiibosoil Jul 14 '26

leetcode in general test your reasoning and logic/algorithm building skill, not a place for beginner learning different operations, object types etc to practice.

For an example, two sum problem you mentioned, requires few things before you start building logic.

  1. How to set class and define method

  2. Know how to instantiate class object and call method

Depending on your learning path above 2 point may not be covered well. Especially true for beginner tutorial that focuses on using existing libraries to perform some data transformation and/or automation.

3. Know different method to store data in memory for efficient retrieval. Ex: dictionary.

Hint is given in the problem itself "exactly one solution", meaning we can assume no duplicate. So key value pair using dictionary is appropriate. Using actual number as key and index as value. But for complete beginner learning basics with no background in data manipulation etc, it will be tricky to spot.

4. Use of enumerate in loop and other pythonic syntax etc.

As others suggested, I'd start off following tutorials and simple data transformation, extraction etc before tackling leetcode.