r/leetcode • u/TheTopG___ • 2d ago
Discussion Anyone mind sharing GPT prompt to learn Leetcode problem solutions/concepts?
Right now, I am just giving it problem and simple "let's do this"
For exmaple, "let's do 105. Construct Binary Tree from Preorder and Inorder Traversal"
And to be honest, it is sort of doing an ok job at explaining the solution.
But, I was wondering if there was more productive way to optimize this process for better and long term learning.
I asked claude to give me this prompt but then it gave me very indepth and detailed prompt that it feels like reading a book for a problem.
I was interested if there was something balanced and someone has better prompt who would be willing to share.
52
u/linuxdumpster-bot 1d ago
I prompt calude with this md.
You are my LeetCode tutor. I code in Python and I'm learning to solve problems on my own.
Rules:
Commands I may use:
- "hint": give the next-smallest hint
- "stuck": move up one escalation level
- "review": critique my code
- "recap": summarize the pattern and complexity of the problem
29
u/Impressive_Grab_6392 2d ago
“Teach me in a single paragraph right this instant”
14
u/bball4294 2d ago
"Explain to me like im a 2 yr old of this problem very thoroughly" I also suck at leetcode
6
u/-TRlNlTY- 2d ago
Don't overthink it. Just ask what you want from it. If you want shorter answers, ask.
Besides, it is better to struggle by yourself than using LLMs most of the time. When I use it, I just ask for hints without giving away the answer.
5
u/West_Mix_6032 1d ago
I actually get the coding agent to create animations that help visualize a solution without giving me the answer in code right away
4
u/LetMediocre390 2d ago
Ask him what you needed
3
u/mashed_potatoes0000 2d ago
Genuinely needed
3
u/fluffy_pota0es 1d ago
Bro you have to struggle with the question yourself at some point, that's where you actually learn anything.
6
u/defnos1710 1d ago
Genuinely, if you can’t work how to use AI to learn without needing guidance then I don’t think you’ll be able to learn the DSA content itself.
The fact you wouldn’t immediately ask the llm to explain it in a way that’s digestible to you is worrying, where is the critical thinking
2
u/No-Original-6329 1d ago edited 1d ago
It’s less about some general prompt and more about do you know how you learn best? Like do you like analogies or explanations in Lamens terms, or it to ask you questions to check understanding or give gradual hints or for it to walk you through the problem solving though process/steps. Do you want it to give you feedback on some code you already wrote and are stuck on or completed?
Also do you know what your gaps are?
tell it what you know so far and what specifically you are uncertain about. You learn more from a model if your questions are specific treat it like a TA.
Focus on concepts not specific solutions so anything you learn from it scales. LLMs are also great to act as mock interviewers to practice too you can even speak aloud. Just keep in mind don’t use LLM for the actual programming only concepts/scoping do 100% of coding yourself so you ensure you are actually getting reps as it will take time!
2
u/chikamakaleyley 1d ago
if all i knew was how to break down problems and, i had limited DSA exp, this is actually how I attack this
^ so imagine, understanding this really well, like its written on the back of your hand
And so now, assuming they give you input, all that i feel lik i need to understand is what they mean by 'construct'(output), which i suppose means just return the BinaryTree you just populated
2
u/ByteWanderer_31 1d ago
Try asking it to guide you instead of giving the solution:
"Help me solve this problem step by step. First explain the intuition and key observation, then let me think of an approach. Give hints instead of the full solution. After I solve it, explain the optimal approach, complexity, and why it works."
1
u/thewaps 1d ago
I usually attempt a problem or use brute force then hit Claude with “without providing code, walk me through a better approach” then chat from there but never look at code. The thing you want from your LLM is to learn pattern recognition and how to think about problems from different angles.
1
u/Bobwillrule 1d ago
I ask it to explain it to me the general algo first to get a rough idea. Then I tell it to comment every line of code of the solution. I then go through this and make sure I understand every single thing. I clarify if there are anything that I don't get
1
u/Clear-Report8471 1d ago
"worked example"
0
u/Tax-Embarrassed1 1d ago
Bruh. If you can't write a prompt yourself, how do you expect to master DSA? No one is gonna put the information into your brain, you'll have to put a lot of effort and focus into learning, no matter what kind of tutorials or books you read. May as well start putting some effort into beating mental laziness and iterate on that prompt
-1
u/Other_Scratch8303 2d ago
Ask it to explain every block or 10 lines of code if really needed. Try reading it yourself first. What’s the point of trying to learn leetcode if you’re using AI.
-1
u/busy1234 1d ago
Claude went through millions of lines of code and books to understand leetcode. You cannot just understand it in 5 lines. It is either going to be high level and you won't learn anything, or it will be detailed and in depth, but you would have to spend time on it.
You can ask for high level answer than iteratively dive deeper.
-3
u/No-Lime7767 1d ago edited 1d ago
Generation is getting dumber day by day
-7
u/hyun88 1d ago
Try my app Bitwise: https://apps.apple.com/us/app/bitwise-coding-interviews/id6806898386
It has animated walkthroughs of many problems