"First, solve the problem. Then, write the code." — John Johnson
This repository is my personal Python problem-solving journal — a dedicated space where I practice programming challenges to strengthen logical thinking and prepare for technical interviews. Every file here is a step forward in becoming a sharper, more confident developer.
Whether it's a pattern puzzle, a recursion riddle, or a classic interview brainteaser — it lives here, broken down and solved with clarity.
- 🧠 Build strong programming logic from the ground up
- 💼 Prepare for technical interviews at top product companies
- 📈 Track consistent progress over time
- 🔄 Revisit and optimize solutions as skills grow
- 📖 Write clean, readable code with comments for learning
│
├── 📂 01_Logic_Building
│ ├── Numbers
│ ├── Strings
│ ├── Lists
│ ├── Dictionaries
│ ├── List_Comprehension
│ └── Basic_Problems
│
├── 📂 02_DSA
│ ├── Arrays
│ │ ├── Traversal
│ │ ├── Two_Pointers
│ │ ├── Hashing
│ │ ├── Sorting
│ │ └── Prefix_Sum (later)
│ │
│ ├── Strings
│ │ ├── Hashing
│ │ ├── Two_Pointers
│ │ └── Sliding_Window (later)
│ │
│ ├── HashMap_Set
│ ├── Math
│ └── Patterns
│
└── README.md
| # | Category | Description | Status |
|---|---|---|---|
| 01 | 🔤 Basics | Syntax, loops, conditionals, I/O | ✅ In Progress |
| 02 | 🔡 Strings | Manipulation, formatting, pattern matching | ✅ In Progress |
| 03 | 📋 Lists & Arrays | Iteration, slicing, searching | ✅ In Progress |
| 04 | 🔁 Recursion | Base cases, recursive breakdown | ✅ In Progress |
| 05 | 🗃️ Dicts & Sets | Hashing, lookup optimization | 🔄 Upcoming |
| 06 | 🏛️ OOP | Classes, inheritance, encapsulation | 🔄 Upcoming |
| 07 | ⚙️ Sorting & Searching | Bubble, merge, binary search | 🔄 Upcoming |
| 08 | 🌟 Patterns | Logic-based print patterns | ✅ In Progress |
| 09 | 🔢 Math & Logic | Number theory, mathematical problems | 🔄 Upcoming |
| 10 | 💼 Interview Questions | Classic and FAANG-style problems | 🔄 Upcoming |
Clone the repository:
git clone https://github.com/MandarK07/Python-Logic-Building.git
cd Python-Logic-BuildingRun any problem file:
python 01_basics/hello_patterns.pyRequirements:
# No external dependencies needed — pure Python 3.x
python --version # Ensure Python 3.6+Each solution file follows a consistent, clean structure:
# ============================================================
# Problem : Find the Second Largest Number in a List
# Category : Lists & Arrays
# Difficulty: Medium
# Date : YYYY-MM-DD
# ============================================================
# 🔍 Approach:
# Iterate through the list, tracking the largest and second largest.
def second_largest(nums):
first = second = float('-inf')
for num in nums:
if num > first:
second = first
first = num
elif num > second and num != first:
second = num
return second if second != float('-inf') else None
# 🧪 Test Cases
print(second_largest([10, 5, 8, 20, 3])) # Output: 10
print(second_largest([5, 5, 5])) # Output: NoneTotal Problems Solved : ██░░░░░░░░ Growing...
Strings : ████░░░░░░ In Progress
Arrays & Lists : ████░░░░░░ In Progress
Patterns : ██████░░░░ Good Progress
Recursion : ███░░░░░░░ In Progress
Interview Questions : █░░░░░░░░░ Just Started
Updated regularly as new problems are added!
| Problem | Category | Difficulty |
|---|---|---|
| Two Sum | Arrays | 🟢 Easy |
| Palindrome Check | Strings | 🟢 Easy |
| Fibonacci (Recursive + Iterative) | Recursion | 🟡 Medium |
| Find All Duplicates | Arrays | 🟡 Medium |
| Balanced Parentheses | Stack / Logic | 🟡 Medium |
| Anagram Groups | Strings / Hashing | 🟡 Medium |
| Binary Search | Searching | 🟢 Easy |
| Merge Sort | Sorting | 🔴 Hard |
reasons = {
"Readable Syntax" : "Focus on logic, not syntax noise",
"Interview Friendly" : "Used widely in coding rounds",
"Rich Ecosystem" : "Great for DSA and scripting both",
"Fast Prototyping" : "Solve and iterate quickly",
}
for reason, value in reasons.items():
print(f"✅ {reason}: {value}")- 📘 Python Docs — Official documentation
- 💻 LeetCode — Interview problem bank
- 🧩 HackerRank — Python challenges
- 📺 CS Dojo — Beginner-friendly DSA
- 📗 Cracking the Coding Interview — Book by Gayle Laakmann McDowell
This is a personal learning repository, but suggestions are always welcome!
If you spot a bug, have a better approach, or want to suggest a new problem:
- Fork the repo
- Create a new branch:
git checkout -b suggest/better-solution - Commit your changes:
git commit -m "Add optimized approach for XYZ" - Open a Pull Request 🎉