This repository contains my personal solutions to LeetCode problems, written in Java, JavaScript, SQL, and pandas.
All solution files are kept directly in the root of the repository. Each file is named after the problem it solves, often including the problem number and a descriptive title.
- ✅ Solutions to a wide range of LeetCode problems
- ✅ Java (
.java), JavaScript (.js), SQL (.sql), and pandas (.py) code - ✅ Clear, readable implementations
- ✅ Covers various topics such as arrays, strings, trees, dynamic programming, recursion, SQL queries, and data manipulation with pandas
- All solution files are in the root directory.
- File naming:
{problem-number}-{problem-title}.{js|java|sql|py}(e.g.,1-two-sum.java,2-add-two-numbers.js,175-combine-two-tables.sql,1876-substrings-of-size-three-with-distinct-characters.py) - No subfolders for topics or languages.
- Java:
Compile and run using:javac ProblemFileName.java java ProblemFileName
- JavaScript:
Run using Node.js:node ProblemFileName.js
- SQL:
Run in your preferred SQL environment (e.g., MySQL, PostgreSQL, LeetCode’s online editor). - pandas (Python):
Run using Python 3:python ProblemFileName.py
This repository serves as a personal reference for:
- Practicing coding problems
- Reviewing core data structures and algorithms
- Preparing for coding interviews
| Problem | Difficulty | LeetCode Link |
|---|---|---|
| 1. Two Sum | Easy | Link |
| 3. Longest Substring Without Repeating Characters | Medium | Link |
| 4. Median Of two sorted arrays | Hard | Link |
| 5. Longest Palindromic Substring | Medium | Link |
| 7. Reverse Integer | Medium | Link |
| 9. Palindrome Number | Easy | Link |
| 13. Roman to Integer | Easy | Link |
| 15. 3Sum | Medium | Link |
| 16. 3Sum Closest | Medium | Link |
| 19. Remove Nth Node From End of List | Medium | Link |
| 21. Merge Two Sorted Lists | Easy | Link |
| 26. Remove Duplicates from Sorted Array | Easy | Link |
| 27. Remove Element | Easy | Link |
| 28. Find the Index of the First Occurrence in a String | Easy | Link |
| 29. Divide Two Integers | Medium | Link |
| 33. Search in Rotated Sorted Array | Medium | Link |
| 35. Search Insert Position | Easy | Link |
| 38. Count and Say | Medium | Link |
| 41. First Missing Positive | Hard | Link |
| 42. Trapping Rain Water | Hard | Link |
| 43. Multiply Strings | Medium | Link |
| 48. Rotate Image | Medium | Link |
| 50. Pow(x, n) | Medium | Link |
| 53. Maximum Subarray | Medium | Link |
| 54. Spiral Matrix | Medium | Link |
| 55. Jump Game | Medium | Link |
| 58. Length of Last Word | Easy | Link |
| 66. Plus One | Easy | Link |
| 69. Sqrt(x) | Easy | Link |
| 70. Climbing Stairs | Easy | Link |
| 73. Set Matrix Zeroes | Medium | Link |
| 74. Search a 2D Matrix | Medium | Link |
| 75. Sort Colors | Medium | Link |
| 80. Remove Duplicates from Sorted Array II | Medium | Link |
| 88. Merge Sorted Array | Easy | Link |
| 94. Binary Tree Inorder Traversal | Easy | Link |
| 118. Pascal’s Triangle | Easy | Link |
| 121. Best Time to Buy and Sell Stock | Easy | Link |
| 122. Best Time to Buy and Sell Stock II | Medium | Link |
| 125. Valid Palindrome | Easy | Link |
| 128. Longest Consecutive Sequence | Medium | Link |
| 136. Single Number | Easy | Link |
| 137. Single Number II | Medium | Link |
| 141. Linked List Cycle | Easy | Link |
| 144. Binary Tree Preorder Traversal | Easy | Link |
| 145. Binary Tree Postorder Traversal | Easy | Link |
| 151. Reverse Words in a String | Medium | Link |
| 152. Maximum Product Subarray | Medium | Link |
| 160. Intersection of Two Linked Lists | Easy | Link |
| 162. Find Peak Element | Medium | Link |
| 164. Maximum Gap | Hard | Link |
| 169. Majority Element | Easy | Link |
| 171. Excel Sheet Column Number | Easy | Link |
| 189. Rotate Array | Medium | Link |
| 191. Number of 1 Bits | Easy | Link |
| 198. House Robber | Medium | Link |
| 202. Happy Number | Easy | Link |
| 204. Count Primes | Medium | Link |
| 205. Isomorphic Strings | Easy | Link |
| 206. Reverse Linked List | Easy | Link |
| 213. House Robber II | Medium | Link |
| 215. Kth Largest Element in an Array | Medium | Link |
| 217. Contains Duplicate | Easy | Link |
| 219. Contains Duplicate II | Easy | Link |
| 229. Majority Element II | Medium | Link |
| 231. Power of Two | Easy | Link |
| 237. Delete Node in a Linked List | Medium | Link |
| 238. Product of Array Except Self | Medium | Link |
| 240. Search a 2D Matrix II | Medium | Link |
| 242. Valid Anagram | Easy | Link |
| 258. Add Digits | Easy | Link |
| 260. Single Number III | Medium | Link |
| 263. Ugly Number | Easy | Link |
| 268. Missing Number | Easy | Link |
| 283. Move Zeroes | Easy | Link |
| 290. Word Pattern | Easy | Link |
| 292. Nim Game | Easy | Link |
| 303. Range Sum Query – Immutable | Easy | Link |
| 326. Power of Three | Easy | Link |
| 342. Power of Four | Easy | Link |
| 344. Reverse String | Easy | Link |
| 345. Reverse Vowels of a String | Easy | Link |
| 347. Top K Frequent Elements | Medium | Link |
| 367. Valid Perfect Square | Easy | Link |
| 374. Guess Number Higher or Lower | Easy | Link |
| 383. Ransom Note | Easy | Link |
| 387. First Unique Character in a String | Easy | Link |
| 389. Find the Difference | Easy | Link |
| 412. Fizz Buzz | Easy | Link |
| 414. Third Maximum Number | Easy | Link |
| 442. Find All Duplicates in an Array | Medium | Link |
| 448. Find All Numbers Disappeared in an Array | Easy | Link |
| 453. Minimum Moves to Equal Array Elements | Easy | Link |
| 455. Assign Cookies | Easy | Link |
| 485. Max Consecutive Ones | Easy | Link |
| 507. Perfect Number | Easy | Link |
| 509. Fibonacci Number | Easy | Link |
| 594. Longest Harmonious Subsequence | Easy | Link |
| 622. Design Circular Queue | Medium | Link |
| 628. Maximum Product of Three Numbers | Easy | Link |
| 693. Binary Number with Alternating Bits | Easy | Link |
| 704. Binary Search | Easy | Link |
| 771. Jewels and Stones | Easy | Link |
| 781. Rabbits in Forest | Medium | Link |
| 790. Domino and Tromino Tiling | Medium | Link |
| 860. Lemonade Change | Easy | Link |
| 876. Middle of the Linked List | Easy | Link |
| 899. Orderly Queue | Hard | Link |
| 905. Sort Array By Parity | Easy | Link |
| 912. Sort an Array | Medium | Link |
| 917. Reverse Only Letters | Easy | Link |
| 941. Valid Mountain Array | Easy | Link |
| 977. Squares of a Sorted Array | Easy | Link |
| 1003. Check If Word Is Valid After Substitutions | Medium | Link |
| 1051. Height Checker | Easy | Link |
| 1089. Duplicate Zeros | Easy | Link |
| 1108. Defanging an IP Address | Easy | Link |
| 1128. Number of Equivalent Domino Pairs | Easy | Link |
| 1200. Minimum Absolute Difference | Easy | Link |
| 1267. Count Servers that Communicate | Medium | Link |
| 1290. Convert Binary Number in a Linked List to Integer | Easy | Link |
| 1295. Find Numbers with Even Number of Digits | Easy | Link |
| 1299. Replace Elements with Greatest Element on Right Side | Easy | Link |
| 1317. Convert Integer to the Sum of Two No-Zero Integers | Easy | Link |
| 1323. Maximum 69 Number | Easy | Link |
| 1324. Print Words Vertically | Medium | Link |
| 1342. Number of Steps to Reduce a Number to Zero | Easy | Link |
| 1346. Check If N and Its Double Exist | Easy | Link |
| 1358. Number of Substrings Containing All Three Characters | Medium | Link |
| 1394. Find Lucky Integer in an Array | Easy | Link |
| 1399. Count Largest Group | Easy | Link |
| 1431. Kids With the Greatest Number of Candies | Easy | Link |
| 1460. Make Two Arrays Equal by Reversing Subarrays | Easy | Link |
| 1464. Maximum Product of Two Elements in an Array | Easy | Link |
| 1470. Shuffle the Array | Easy | Link |
| 1480. Running Sum of 1d Array | Easy | Link |
| 1491. Average Salary Excluding the Minimum and Maximum Salary | Easy | Link |
| 1492. The kth Factor of n | Medium | Link |
| 1512. Number of Good Pairs | Easy | Link |
| 1518. Water Bottles | Easy | Link |
| 1523. Count Odd Numbers in an Interval Range | Easy | Link |
| 1524. Number of Sub-arrays With Odd Sum | Medium | Link |
| 1534. Count Good Triplets | Easy | Link |
| 1550. Three Consecutive Odds | Easy | Link |
| 1567. Maximum Length of Subarray With Positive Product | Medium | Link |
| 1572. Matrix Diagonal Sum | Easy | Link |
| 1641. Count Sorted Vowel Strings | Medium | Link |
| 1684. Count the Number of Consistent Strings | Easy | Link |
| 1685. Sum of Absolute Differences in a Sorted Array | Medium | Link |
| 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers | Medium | Link |
| 1694. Reformat Phone Number | Easy | Link |
| 1748. Sum of Unique Elements | Easy | Link |
| 1749. Maximum Absolute Sum of Any Subarray | Medium | Link |
| 1752. Check if Array Is Sorted and Rotated | Easy | Link |
| 1768. Merge Strings Alternately | Easy | Link |
| 1780. Check if Number is a Sum of Powers of Three | Medium | Link |
| 1796. Second Largest Digit in a String | Easy | Link |
| 1800. Maximum Ascending Subarray Sum | Easy | Link |
| 1807. Evaluate the Bracket Pairs of a String | Medium | Link |
| 1816. Truncate Sentence | Easy | Link |
| 1832. Check if the Sentence Is Pangram | Easy | Link |
| 1833. Maximum Ice Cream Bars | Medium | Link |
| 1859. Sorting the Sentence | Easy | Link |
| 1863. Sum of All Subset XOR Totals | Easy | Link |
| 1920. Build Array from Permutation | Easy | Link |
| 1922. Count Good Numbers | Medium | Link |
| 1929. Concatenation of Array | Easy | Link |
| 1935. Maximum Number of Words You Can Type | Easy | Link |
| 1941. Check if All Characters Have Equal Number of Occurrences | Easy | Link |
| 1945. Sum of Digits of String After Convert | Easy | Link |
| 1957. Delete Characters to Make Fancy String | Easy | Link |
| 1976. Number of Ways to Arrive at Destination | Medium | Link |
| 2000. Reverse Prefix of Word | Easy | Link |
| 2011. Final Value of Variable After Performing Operations | Easy | Link |
| 2016. Maximum Difference Between Increasing Elements | Easy | Link |
| 2023. Number of Pairs of Strings With Concatenation Equal to Target | Medium | Link |
| 2033. Minimum Operations to Make a Uni-Value Grid | Medium | Link |
| 2079. Watering Plants | Medium | Link |
| 2085. Count Common Words With One Occurrence | Easy | Link |
| 2094. Finding 3-Digit Even Numbers | Medium | Link |
| 2108. Find First Palindromic String in the Array | Easy | Link |
| 2109. Adding Spaces to a String | Medium | Link |
| 2115. Find All Possible Recipes from Given Supplies | Medium | Link |
| 2149. Rearrange Array Elements by Sign | Medium | Link |
| 2150. Find All Lonely Numbers in the Array | Medium | Link |
| 2154. Keep Multiplying Found Values by Two | Easy | Link |
| 2161. Partition Array According to Given Pivot | Medium | Link |
| 2169. Count Operations to Obtain Zero | Easy | Link |
| 2176. Count Equal and Divisible Pairs in an Array | Easy | Link |
| 2185. Counting Words With a Given Prefix | Easy | Link |
| 2206. Divide Array Into Equal Pairs | Easy | Link |
| 2225. Find Players With Zero or One Losses | Medium | Link |
| 2226. Maximum Candies Allocated to K Children | Medium | Link |
| 2235. Add Two Integers | Easy | Link |
| 2264. Largest 3-Same-Digit Number in String | Easy | Link |
| 2348. Number of Zero-Filled Subarrays | Medium | Link |
| 2351. First Letter to Appear Twice | Easy | Link |
| 2357. Make Array Zero by Subtracting Equal Amounts | Easy | Link |
| 2379. Minimum Recolors to Get K Consecutive Black Blocks | Easy | Link |
| 2390. Removing Stars From a String | Medium | Link |
| 2396. Strictly Palindromic Number | Medium | Link |
| 2401. Longest Nice Subarray | Medium | Link |
| 2410. Maximum Matching of Players With Trainers | Medium | Link |
| 2413. Smallest Even Multiple | Easy | Link |
| 2428. Maximum Sum of an Hourglass | Medium | Link |
| 2433. Find The Original Array of Prefix Xor | Medium | Link |
| 2460. Apply Operations to an Array | Easy | Link |
| 2465. Number of Distinct Averages | Easy | Link |
| 2469. Convert the Temperature | Easy | Link |
| 2503. Maximum Number of Points From Grid Queries | Hard | Link |
| 2520. Count the Digits That Divide a Number | Easy | Link |
| 2521. Distinct Prime Factors of Product of Array | Medium | Link |
| 2523. Closest Prime Numbers in Range | Medium | Link |
| 2529. Maximum Count of Positive Integer and Negative Integer | Easy | Link |
| 2535. Difference Between Element Sum and Digit Sum of an Array | Easy | Link |
| 2537. Count the Number of Good Subarrays | Medium | Link |
| 2551. Put Marbles in Bags | Hard | Link |
| 2560. House Robber IV | Medium | Link |
| 2562. Find the Array Concatenation Value | Easy | Link |
| 2566. Maximum Difference by Remapping a Digit | Easy | Link |
| 2570. Merge Two 2D Arrays by Summing Values | Easy | Link |
| 2579. Count Total Number of Colored Cells | Medium | Link |
| 2586. Count the Number of Vowel Strings in Range | Easy | Link |
| 2594. Minimum Time to Repair Cars | Hard | Link |
| 2610. Convert an Array Into a 2D Array With Conditions | Medium | Link |
| 2656. Maximum Sum With Exactly K Elements | Easy | Link |
| 2683. Neighboring Bitwise XOR | Easy | Link |
| 2685. Count the Number of Complete Components | Medium | Link |
| 2706. Buy Two Chocolates | Easy | Link |
| 2716. Minimize String Length | Easy | Link |
| 2733. Neither Minimum nor Maximum | Easy | Link |
| 2761. Prime Pairs With Target Sum | Medium | Link |
| 2769. Find the Maximum Achievable Number | Easy | Link |
| 2778. Sum of Squares of Special Elements | Easy | Link |
| 2780. Minimum Index of a Valid Split | Medium | Link |
| 2798. Number of Employees Who Met the Target | Easy | Link |
| 2818. Apply Operations to Maximize Score | Hard | Link |
| 2828. Check if a String Is an Acronym of Words | Easy | Link |
| 2843. Count Symmetric Integers | Easy | Link |
| 2873. Maximum Value of an Ordered Triplet I | Easy | Link |
| 2874. Maximum Value of an Ordered Triplet II | Medium | Link |
| 2894. Divisible and Non-divisible Sums Difference | Easy | Link |
| 2900. Longest Unequal Adjacent Groups Subsequence I | Medium | Link |
| 2942. Find Words Containing Character | Easy | Link |
| 2965. Find Missing and Repeated Values | Easy | Link |
| 3005. Count Elements With Maximum Frequency | Easy | Link |
| 3024. Type of Triangle | Easy | Link |
| 3028. Ant on the Boundary | Easy | Link |
| 3065. Minimum Operations to Exceed Threshold Value I | Easy | Link |
| 3066. Minimum Operations to Exceed Threshold Value II | Medium | Link |
| 3079. Find the Sum of Encrypted Integers | Easy | Link |
| 3099. Harshad Number | Easy | Link |
| 3105. Longest Strictly Increasing or Strictly Decreasing Subarray | Easy | Link |
| 3108. Minimum Cost Walk in Weighted Graph | Hard | Link |
| 3110. Score of a String | Easy | Link |
| 3136. Valid Word | Easy | Link |
| 3151. Special Array I | Easy | Link |
| 3169. Count Days Without Meetings | Medium | Link |
| 3190. Find Minimum Operations to Make All Elements Divisible by Three | Easy | Link |
| 3191. Minimum Operations to Make Binary Array Elements Equal to One I | Medium | Link |
| 3206. Alternating Groups I | Easy | Link |
| 3208. Alternating Groups II | Medium | Link |
| 3211. Generate Binary Strings Without Adjacent Zeros | Medium | Link |
| 3232. Find if Digit Game Can Be Won | Easy | Link |
| 3280. Convert Date to Binary | Easy | Link |
| 3289. The Two Sneaky Numbers of Digitville | Medium | Link |
| 3304. Find the K-th Character in String Game I | Easy | Link |
| 3305. Count of Substrings Containing Every Vowel and K Consonants I | Medium | Link |
| 3306. Count of Substrings Containing Every Vowel and K Consonants II | Hard | Link |
| 3330. Find the Original Typed String I | Medium | Link |
| 3356. Zero Array Transformation II | Hard | Link |
| 3375. Minimum Operations to Make Array Values Equal to K | Hard | Link |
| 3394. Check if Grid can be Cut into Sections | Medium | Link |
| 3396. Minimum Number of Operations to Make Elements in Array Distinct | Medium | Link |
| 3423. Maximum Difference Between Adjacent Elements in a Circular Array | Easy | Link |
| 3442. Maximum Difference Between Even and Odd Frequency I | Easy | Link |
| 3452. Sum of Good Numbers | Easy | Link |
| 3467. Transform Array by Parity | Easy | Link |
| 3477. Fruits Into Baskets II | Medium | Link |
| 3487. Maximum Unique Subarray Sum After Deletion | Easy | Link |
| 3492. Maximum Containers on a Ship | Easy | Link |
| 3498. Reverse Degree of a String | Easy | Link |
| 3502. Minimum Cost to Reach Every Position | Medium | Link |
| 3522. Calculate Score After Performing Instructions | Easy | Link |
| 3523. Make Array Non-decreasing | Medium | Link |
| 3541. Find Most Frequent Vowel and Consonant | Easy | Link |
| 3550. Smallest Index With Digit Sum Equal to Index | Easy | Link |
| 3582. Generate Tag for Video Caption | Easy | Link |
| 3622. Check Divisibility by Digit Sum and Product | Easy | Link |
| Problem | Difficulty | LeetCode Link |
|---|---|---|
| 1. Two Sum | Easy | Link |
| 4. Median of Two Sorted Arrays | Hard | Link |
| 9. Palindrome Number | Easy | Link |
| 13. Roman to Integer | Easy | Link |
| 21. Merge Two Sorted Lists | Easy | Link |
| 26. Remove Duplicates from Sorted Array | Easy | Link |
| 27. Remove Element | Easy | Link |
| 33. Search in Rotated Sorted Array | Medium | Link |
| 35. Search Insert Position | Easy | Link |
| 55. Jump Game | Medium | Link |
| 58. Length of Last Word | Easy | Link |
| 70. Climbing Stairs | Easy | Link |
| 80. Remove Duplicates from Sorted Array II | Medium | Link |
| 136. Single Number | Easy | Link |
| 141. Linked List Cycle | Easy | Link |
| 145. Binary Tree Postorder Traversal | Easy | Link |
| 152. Maximum Product Subarray | Medium | Link |
| 171. Excel Sheet Column Number | Easy | Link |
| 191. Number of 1 Bits | Easy | Link |
| 198. House Robber | Medium | Link |
| 342. Power of Four | Easy | Link |
| 386. Lexicographical Numbers | Medium | Link |
| 509. Fibonacci Number | Easy | Link |
| 790. Domino and Tromino Tiling | Medium | Link |
| 1399. Count Largest Group | Easy | Link |
| 1518. Water Bottles | Easy | Link |
| 1534. Count Good Triplets | Easy | Link |
| 1920. Build Array from Permutation | Easy | Link |
| 2079. Watering Plants | Medium | Link |
| 2176. Count Equal and Divisible Pairs in an Array | Easy | Link |
| 2348. Number of Zero-Filled Subarrays | Medium | Link |
| 2460. Apply Operations to an Array | Easy | Link |
| 2469. Convert the Temperature | Easy | Link |
| 2619. Array Prototype Last | Easy | Link |
| 2620. Counter | Easy | Link |
| 2621. Sleep | Easy | Link |
| 2626. Array Reduce Transformation | Easy | Link |
| 2629. Function Composition | Easy | Link |
| 2634. Filter Elements from Array | Easy | Link |
| 2635. Apply Transform Over Each Element in Array | Easy | Link |
| 2665. Counter II | Easy | Link |
| 2666. Allow One Function Call | Easy | Link |
| 2667. Create Hello World Function | Easy | Link |
| 2677. Chunk Array | Easy | Link |
| 2683. Neighboring Bitwise XOR | Easy | Link |
| 2703. Return Length of Arguments Passed | Easy | Link |
| 2704. To Be Or Not To Be | Easy | Link |
| 2723. Add Two Promises | Easy | Link |
| 2798. Number of Employees Who Met the Target | Easy | Link |
| 2843. Count Symmetric Integers | Easy | Link |
| 3000. Maximum Area of Longest Diagonal Rectangle | Easy | Link |
| 3005. Count Elements With Maximum Frequency | Easy | Link |
| 3024. Type of Triangle | Easy | Link |
| 3151. Special Array I | Easy | Link |
| 3423. Maximum Difference Between Adjacent Elements in a Circular Array | Easy | Link |
| 3467. Transform Array by Parity | Easy | Link |
| 3582. Generate Tag for Video Caption | Easy | Link |
| Problem | Difficulty | LeetCode Link |
|---|---|---|
| 182. Duplicate Emails | Easy | Link |
| 183. Customers Who Never Order | Easy | Link |
| 577. Employee Bonus | Easy | Link |
| 584. Find Customer Referee | Easy | Link |
| 595. Big Countries | Easy | Link |
| 619. Biggest Single Number | Easy | Link |
| 741. Find Total Time Spent by Each Employee | Easy | Link |
| 1148. Article Views I | Easy | Link |
| 1378. Replace Employee ID With The Unique Identifier | Easy | Link |
| 1527. Patients With a Condition | Easy | Link |
| 1581. Customer Who Visited but Did Not Make Any Transactions | Easy | Link |
| 1683. Invalid Tweets | Easy | Link |
| 1693. Daily Leads and Partners | Easy | Link |
| 1757. Recyclable and Low Fat Products | Easy | Link |
| 1978. Employees Whose Manager Left the Company | Easy | Link |
| 2356. Number of Unique Subjects Taught by Each Teacher | Easy | Link |
| Problem | Difficulty | LeetCode Link |
|---|---|---|
| 2879. Display the First Three Rows | Easy | Link |
| 2881. Create a New Column | Easy | Link |
| 2882. Drop Duplicate Rows | Easy | Link |
| 2884. Modify Columns | Easy | Link |
| 2886. Change Data Type | Easy | Link |
| 2888. Reshape Data: Concatenate | Easy | Link |
Contributions are welcome!
If you’d like to add a new solution or improve an existing one:
- Fork the repository
- Add your solution in the root directory
- Use the existing naming convention
- Open a pull request
Check out my LeetCode submissions and progress:
👉 https://leetcode.com/Sanjay3005v
Sanjay V
📧 sanjay3005v@gmail.com
🔗 GitHub | LinkedIn
Feel free to star ⭐ the repository if you find it useful!
Leave a Reply