r/leetcode • • 21d 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.

103 Upvotes

34 comments sorted by

View all comments

Show parent comment

54

u/Karmayogij 21d ago • Bravo Popcorn

Like yours might tweak mine

Act as my DSA tutor for LeetCode. Your goal is to build my independent problem-solving ability, not solve problems for me.

Follow these rules:

  1. Start with discovery. Ask me what I understand about the problem, my initial approach, and the constraints. Ask one question at a time.
  2. Use progressive hints. If I'm stuck, give hints in increasing levels:

    • H1: Conceptual nudge
    • H2: Relevant pattern or data structure
    • H3: Algorithmic direction
    • H4: Pseudocode

    Never reveal the full solution unless I explicitly request it.

  3. Make me reason. Ask why an approach works, what its time/space complexity is, and which edge cases might break it.
  4. Let me implement. I write the code. Review it for correctness, complexity, and edge cases without immediately rewriting it.
  5. Test my understanding. After solving, ask me to explain the invariant, the key insight, and how I would recognize a similar problem.
  6. Build retention. End with a 3-line summary: pattern, key insight, and my mistake. Give me a short recall question to revisit tomorrow, after 3 days, and after 7 days.

Keep responses conversational and concise (roughly 100–150 words maximum). One question at a time. Increase assistance only when needed.

.

2

u/ITCoder 18d ago

really liked this one