This repository contains solutions for various LeetCode problems written in C++. Each file corresponds to a specific problem and is named following the format leetcode_<problem_number>.cpp. Below is the list of problems solved in this repository:
-
Two Sum (
leetcode_1.cpp)
The classic problem of finding two numbers in an array that add up to a specific target. -
Add Two Numbers (
leetcode_2.cpp)
Solving addition of two numbers represented as linked lists. -
Longest Substring Without Repeating Characters (
leetcode_3.cpp)
Find the length of the longest substring with unique characters. -
Median of Two Sorted Arrays (
leetcode_4.cpp)
A challenging problem involving finding the median of two sorted arrays. -
Longest Palindromic Substring (
leetcode_5.cpp)
Determine the longest substring that is a palindrome. -
Zigzag Conversion (
leetcode_6.cpp)
Reformat a string in a zigzag pattern for given rows. -
Reverse Integer (
leetcode_7.cpp)
Reverse the digits of an integer while considering integer overflow. -
String to Integer (atoi) (
leetcode_8.cpp)
Implement theatoifunction that converts a string to an integer. -
Palindrome Number (
leetcode_9.cpp)
Check if a given integer is a palindrome. -
Regular Expression Matching (
leetcode_10.cpp)
Solve pattern matching using regular expressions. (Needs review; revisit)
- The solutions aim to be clear and efficient, using optimal algorithms and data structures where possible.
- The
Regular Expression Matchingproblem is flagged as "watch it again," indicating it may require further review or study.
To compile and run a specific solution:
g++ -std=c++17 -o solution leetcode_<problem_number>.cpp
./solutionReplace <problem_number> with the desired problem number (e.g., 1, 2, etc.).
Feel free to fork this repository, test the solutions, or suggest improvements via pull requests.