Competitive Programming teaches problem-solving and algorithmic thinking using languages like Java, C++, and Python.
- ✅ Data structures (Arrays, Linked Lists, Trees, Graphs)
- ✅ Algorithms (Sorting, Searching, Dynamic Programming)
- ✅ Mathematical concepts (Number theory, Geometry)
- ✅ String algorithms
- ✅ Graph algorithms
This folder contains solutions to various competitive programming problems, implemented primarily in Java.
CP/
├── README.md
├── watermelon.java # Basic problem
├── str.java # String manipulation
├── sort.java # Sorting algorithms
├── sqrt.md # Math algorithms
├── problem71A.java # Pattern problems
├── prefixSum.java # Prefix sum technique
├── multiple.java # Modulo operations
├── maxMin.java # Min/Max problems
├── lastDig.java # Digit operations
├── Resources/
│ └── resources.txt # Learning resources
└── .cph/ # Problem metadata
- Understand the problem statement
- Analyze time and space complexity
- Choose the right algorithm
- Implement the solution
- Test with examples
- Optimize if needed
- Problem solutions in Java
- Algorithm explanations
- Complexity analysis
- Common patterns
Master problem-solving and algorithms! 🚀 <<<<<<< HEAD
Yes. Since this is a temporary chat, save the prompts below somewhere safe (Notion/GitHub/README/text file).
These prompts are designed specifically for:
- Binary Search
- Binary Search on Answer
- Placement-style DSA
- Java
- Pattern recognition
- Interview thinking
Copy this entire prompt and reuse it for every problem.
You are my DSA mentor.
I am solving Binary Search problems in Java.
For every problem, follow this exact structure:
1. First explain:
- What type of binary search problem this is
- Classic BS / Lower Bound / Upper Bound / Rotated Array / Peak / Binary Search on Answer / Matrix BS
2. Then explain:
- What is the search space
- Why binary search works
- What is monotonic in this problem
3. Then derive intuition slowly.
4. Then explain brute force briefly.
5. Then optimize to binary search.
6. Then explain:
- low initialization
- high initialization
- why mid works
- why we move left/right
7. If Binary Search on Answer:
explain the isPossible(mid) logic deeply.
8. Then provide clean Java code.
9. Then dry run on sample input.
10. Then explain time complexity.
11. Then give:
- common mistakes
- edge cases
- interview tips
12. Never skip reasoning steps.
13. Do NOT directly give solution immediately.
Help me think first.
14. After solution, give:
- similar LeetCode problems
- pattern similarity
15. Use beginner-friendly language but teach interview-level thinking.
Give me ONLY hints for this Binary Search problem.
Do NOT give full solution.
Help me discover:
- search space
- monotonic condition
- isPossible(mid)
One hint at a time.
This is the most important one.
Teach me this Binary Search on Answer problem step by step.
Explain:
1. What is the answer range?
2. Why is answer monotonic?
3. How do we design isPossible(mid)?
4. Are we minimizing or maximizing?
5. When do we move left or right?
Then help me derive the final code myself.
I will give my Java Binary Search code.
Do NOT rewrite immediately.
First:
1. Find logical mistake
2. Explain WHY it breaks
3. Explain which binary search invariant failed
4. Explain edge case failing
5. Then minimally fix my code
Focus on teaching, not replacing my code.
Very useful for interviews.
I want to master Binary Search pattern recognition.
For this problem explain:
- How to IDENTIFY this is binary search
- What clues in statement indicate BS
- Whether this is:
- exact search
- lower bound
- upper bound
- answer search
- rotated array
- peak finding
Then compare it with 3 similar LeetCode problems.
Revise Binary Search patterns for interviews.
Create:
- pattern summary
- templates
- common tricks
- edge cases
- mistakes
- intuition rules
Use Java.
=======
b37fb03a446b0fa85f20401d260501addacb53ad