LeetCode Answers repository contains Python solutions to a variety of common algorithmic problems frequently encountered in coding interviews and competitive programming. The repository is structured to provide clear, concise implementations of popular problems.
Features
- Solutions to classic algorithmic problems such as Two Sum, Add Two Numbers (linked list), Longest Substring Without Repeating Characters, Binary Search Median, Merge Intervals, and Quick Sort.
- Both iterative and divide-and-conquer approaches for median finding.
- Clean, readable Python code with explanatory comments.
Tech Stack
- Python 3
Getting Started
Prerequisites
- Python 3.x installed on your system
Installation
Clone the repository:
git clone https://github.com/justin-napolitano/LeetCode.git
cd LeetCode
Running Solutions
Each problem solution is implemented in its own Python file. You can run them directly using Python. For example, to run the binary search median example:
python q4_binary_search_median.py
Note: Some files contain classes and methods that require you to instantiate the class or call methods with appropriate inputs.
Project Structure
q1_two_sum.py: Solution for the Two Sum problem.q2_add_two_numbers_singly_linked_list.py: Adds two numbers represented by singly linked lists.q3_longest_substring.py: Finds the length of the longest substring without repeating characters.q4_binary_search_median.py: Median of two sorted arrays using binary search approach.q4_merge_median.py: Median of two sorted arrays using merge approach.q_56_list_intersection.py: Merges overlapping intervals.quickSort.py: Quick sort implementation.README.md: This file.
Future Work / Roadmap
- Add more problem solutions covering a wider range of algorithmic challenges.
- Include unit tests for each solution.
- Optimize existing solutions for performance and readability.
- Add detailed usage examples and input/output formats.
- Support additional programming languages.