Welcome to the Leetcode Solutions Repository created by Vijay Bhatia! This repository contains solutions to various Leetcode problems using Python and SQL. The problems are categorized based on their difficulty levels: Easy, Medium, and Hard.
The repository is organized into the following directories:
-
Easy: Contains solutions to easy-level Leetcode problems.
- backspaceCompare.py: Solution for comparing two strings after backspace operations.
- best_time_buy_sell.py: Solution for best_time to buy & sell stocks.
- binary_search.py: Solution for binary search.
- contains_dup.py: Solution for checking if an array contains duplicates.
- count_parenthesis.py: Solution for validating balanced parentheses in a string.
- duplicate_array.py: Solution for finding duplicates in an array.
- kth_largest.py: Solution for finding the kth largest element in an array.
- merge_2_sorted_linkedlist.py: Solution for merging two sorted linkedlist.
- merge_sorted_array.py: Solution for merging two sorted arrays.
- remove_adj_dup.py: Solution for removing adjacent duplicates in a string.
- remove_dup_from_sorted.py: Solution for removing duplicate from sorted array.
- reverse_linked_list.py: Solution for reversing a linked list.
- reverse_string.py : Solution for reversing a string.
- reverse_vowels.py: Solution for reversing vowels in a string.
- roman_to_number2.py: Solution for converting Roman numerals to integers.
- search_rotated_array.py: Solution for Search in Rotated Sorted Array.
- second_largest.py: Solution for finding the second largest element in an array.
- two_sum.py: Solution for finding two indices in an array that sum up to a target value.
- valid_anagram.py: Solution for checking if two strings are anagrams.
- valid_palindrome.py: Solution for checking palindrome.
-
Medium: Contains solutions to medium-level Leetcode problems.
- 3sum.py : Solution for threeSum problem with two pointers.
- encode_decode.py : PREMIUM Solution for encoding and Decoding Strings.
- find_duplicate_number.py : Solution for finding the Duplicate Number in an array without modifying. (Floyd's Tortoise and Hare (Cycle Detection)).
- rotate_image.py: Solution for rotation of n x n 2D matrix representing an image by 90 degrees clockwise.
- group_anagrams.py: Solution for grouping anagrams.
- product_array.py: Solution for Products of Array Except Self.
- removing_stars_from_string.py: Solution for removing stars from a string.
- twoSum_2.py : Solution for finding Two Sum using 2 Pointers.
- top_k_frequent.py : Solution for finding the k most frequent elements.
-
Easy: Contains solutions to easy-level SQL problems.
- article_views.sql: Solution for finding all the authors that viewed at least one of their own articles.
- avg_exp_employees.sql: Solution for finding the average experience years of all the employees for each project.
- claims.sql: Solution for finding claims by month CVS.
- customer_visited_no_trans.sql: Solution for finding customers who visited but did not make any transactions.
- invalid_tweets.sql: Solution for finding invalid tweets.
- report.sql: Solution for reporting the number of employees reporting to each employee.
- replace_empid.sql: Solution for Replace Employee ID With The Unique Identifier
- second_highest_sal.sql: Solution for identifying to get the second highest salary.
- sp_global_imp_customers.sql: Solution for identifying important customers.
- toptraveller.sql: Solution to report the distance traveled by each user.
- well_paid_emp.sql: Solution for finding employees who earn more than their managers.
-
Medium: Contains solutions to medium-level SQL problems.
- consecutive Numbers.sql Solution for Find all numbers that appear at least three times consecutively.
- exchange_seats.sql: Solution for Swap adjacent seat numbers.
- manager_5_reports.sql: Solution for finding managers with at least five direct reports.
- NTH_highest_salary.sql: Solution for finding the Nth highest salary.
- rank_scores.sql: Solution for Rank scores without skipping numbers.
- second_highest_salary.sql: Solution for finding the second highest salary.
-
Hard: Contains solutions to hard level SQL problems.
- dept_sal.sql: Solution for Department Top Three Salaries
-
Clone the repository:
git clone https://github.com/vbhatia9/leetcodevb.git
-
Navigate to the desired directory to find the solution you are looking for.
-
Run the Python scripts using:
python filename.py- Execute the SQL queries in your preferred SQL environment.
Contributing π€ Feel free to contribute to this repository by submitting pull requests. Make sure to follow the existing code style and include appropriate comments and documentation.
License π This repository is licensed under the MIT License.