Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LeetCode Problems & Solutions Repository

LeetCode Banner Python Contributions Welcome

Table of Contents

Introduction

Welcome to my comprehensive collection of LeetCode problems and Python programming solutions. This repository serves as both a personal archive of my coding journey and a resource for fellow programmers seeking to improve their problem-solving skills.

Each solution is meticulously documented with:

  • Problem statement and constraints
  • Approach explanation with reasoning
  • Time and space complexity analysis
  • Edge cases consideration
  • Alternative solutions where applicable

Whether you're preparing for technical interviews, improving your algorithmic thinking, or simply looking to practice Python programming, this repository aims to be a valuable resource in your learning journey.

Repository Structure

The repository is organized into individual problem directories, each containing:

  1. **Problem **: A problem name
  2. Solution Files: Implementation of the solution in Python
repository-root/
β”œ
β”‚   β”œβ”€β”€ problem-1/
β”‚   β”‚   β”œβ”€β”€ solution.py
β”‚   β”‚    
β”‚   β”‚    
β”‚   └── problem-2/
β”‚       β”œβ”€β”€ solution.py
β”‚       
 
   

Problem Categories

LeetCode Problems

Problem Directory Difficulty Topics Description
buildArray-in-leetcode-main Easy Arrays Array manipulation problem
kidsWithCandies-in-leetcode-main Easy Arrays Distribution algorithm
numIdenticalPairs-in-leetcode-main Easy Arrays, Hash Table Finding identical pairs
numberOfEmployeesWhoMetTarget-in-leetcode-main Easy Arrays Employee performance evaluation
smallerNumbersThanCurrent-in-leetcode-main Easy Arrays, Sorting Count smaller elements
serch-insert-position-leetcode-main Easy Binary Search Position finding algorithm
maxProductDifference-main Easy Arrays, Math Maximum product difference calculation
minimumOperations-main Medium Greedy Optimization problem
climbing-stair--main Easy Dynamic Programming Classic DP problem

Data Structures

Lists

  • list-sort-main: Different sorting techniques for lists
  • clear-a-list-main: Methods to clear or reset lists
  • copy-of-list-in-in-python-main: Deep vs shallow copy operations
  • exist-in-a-list-in-in-python-main: Checking for element existence

Dictionaries

  • merge-two-dict-main: Techniques to merge dictionaries
  • max-in-dict-main: Finding maximum values in dictionaries
  • min-in-dict-in-python-main: Finding minimum values in dictionaries
  • dict-sort-by-key-main: Sorting dictionaries by keys
  • dict-sort-by-value-in-python-main: Sorting dictionaries by values
  • reverse-a-dict.-main: Reversing key-value pairs
  • sum-of-dict-main: Summing dictionary values

Strings

  • reverse-a-string-main: String reversal techniques
  • to-lowercase-main: Case conversion methods
  • without-vowel-main: String manipulation removing vowels
  • lower-case-main: Lowercase operations

Algorithms

Mathematical Algorithms

  • count-of-digits-in-python-main: Digit counting techniques
  • digit-sum-main: Summing digits in numbers
  • fizzbuzz-main: Classic FizzBuzz implementation
  • common-factor-in-python-main: Finding common factors

Searching and Sorting

  • list-sort-main: Various sorting algorithms
  • min-number-main: Finding minimum values
  • smallest-even-numbers-main: Conditional minimum finding

Recursion

  • recursion--main: Recursive algorithm implementations

Python Programming Concepts

  • generator-main: Python generator functions and expressions
  • convert-list-to-dict-main: Data structure conversion
  • avg--n-list-number-main: Average calculation examples
  • avg-of-even--number-main: Conditional average calculation
  • square-even-odd-cube-main: Applying different operations based on conditions

Pattern Printing

  • pyramid-traingle-main: Triangle pattern printing
  • invert-pyramid-main: Inverted pattern printing
  • right-angle-main: Right-angled triangle patterns

Solution Approach

My solutions generally follow these principles:

  1. Readability First: Clean, well-commented code that's easy to understand
  2. Efficiency: Optimized for both time and space complexity
  3. Pythonic: Leveraging Python's built-in features and best practices
  4. Multiple Approaches: When relevant, providing both brute force and optimized solutions
  5. Edge Cases: Careful handling of boundary conditions and special inputs

How to Use This Repository

For Learning:

  1. Browse to a problem you're interested in
  2. Read the problem statement
  3. Try to solve it yourself first
  4. Compare your solution with mine and learn alternative approaches
  5. Study the time and space complexity analysis

For Interview Preparation:

  1. Use the difficulty tags to select appropriate problems
  2. Time yourself while solving them
  3. Review the optimal solutions
  4. Practice explaining your approach out loud

For Contributors:

  1. Check the contribution guidelines below
  2. Pick a problem that hasn't been solved yet
  3. Follow the repository structure
  4. Submit a pull request

Implementation Details

Most solutions are implemented in Python 3, taking advantage of:

  • Collections module (Counter, defaultdict, etc.)
  • List comprehensions
  • Generator expressions
  • Standard library functions
  • Type hints (in newer solutions)

Time & Space Complexity Analysis

Each solution includes a detailed analysis of:

  • Time Complexity: Big O notation explaining the running time
  • Space Complexity: Additional memory requirements
  • Optimization Considerations: Trade-offs between time and space

Contribution Guidelines

I welcome contributions to this repository! Here's how you can help:

  1. Add New Problems:

    • Follow the existing directory structure
    • Include problem statement, solution, and explanation
    • Add appropriate test cases
  2. Improve Existing Solutions:

    • Optimize for better time/space complexity
    • Improve code readability
    • Add alternative approaches
  3. Fix Issues:

    • Correct bugs or errors in solutions
    • Improve explanations
    • Enhance documentation

Pull Request Process:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-solution)
  3. Commit your changes (git commit -m 'Add solution for Problem X')
  4. Push to the branch (git push origin feature/amazing-solution)
  5. Open a Pull Request with a detailed description

Learning Resources

To complement the solutions in this repository, here are some recommended resources:

  • Books:

    • "Cracking the Coding Interview" by Gayle Laakmann McDowell
    • "Elements of Programming Interviews" by Adnan Aziz, Tsung-Hsien Lee, and Amit Prakash
    • "Python Algorithms" by Magnus Lie Hetland
  • Online Platforms:

    • LeetCode (of course!)
    • HackerRank
    • CodeSignal
    • GeeksforGeeks
  • YouTube Channels:

    • Back To Back SWE
    • Kevin Naughton Jr.
    • Nick White
    • Tech Dose

FAQ

Q: Why are some solutions missing explanations? A: I'm continually updating the repository. If you find a solution without an explanation, feel free to contribute!

Q: How do I request a specific problem solution? A: Open an issue with the problem link and details.

Q: Can I use these solutions in interviews? A: These solutions are for learning purposes. In interviews, it's important to understand the approach rather than memorizing solutions.

Q: How often is this repository updated? A: I try to add new solutions regularly, typically adding 5-10 new problems each month.

Contact Information


If you find this repository helpful, please consider giving it a star! Your support encourages me to keep adding more solutions and improving existing ones.

Happy Coding! πŸš€

LeetCode Topics

Tree

Problem Name Difficulty
0112-path-sum
0144-binary-tree-preorder-traversal Easy

Depth-First Search

Problem Name Difficulty
0112-path-sum
0144-binary-tree-preorder-traversal Easy

Breadth-First Search

Problem Name Difficulty
0112-path-sum

Binary Tree

Problem Name Difficulty
0112-path-sum
0144-binary-tree-preorder-traversal Easy

Array

Problem Name Difficulty
2815-max-pair-sum-in-an-array Easy
3005-count-elements-with-maximum-frequency Easy

Hash Table

Problem Name Difficulty
2815-max-pair-sum-in-an-array Easy
3005-count-elements-with-maximum-frequency Easy

Counting

Problem Name Difficulty
3005-count-elements-with-maximum-frequency Easy

Stack

Problem Name Difficulty
0144-binary-tree-preorder-traversal Easy

About

A well-organized collection of 50+ LeetCode problems solved in Python with clear explanations, edge case handling, and complexity analysis. Includes categorized solutions for arrays, strings, dynamic programming, recursion, greedy algorithms, and more. Ideal for coding interview prep, Python learners, and contributors. πŸš€ βœ… Beginner to Advanced

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages