Leetcode#
Note
This section of my notes is directed towards interview prep and leetcode practice. I’ll host solutions and problems that I’ve worked on here, so that I can keep track of my preparation.
All problems are the property of Leetcode and the rights thereof belong to them.
- LC0001 - 2-Sum-Problem (EASY)
- LC0002 - Add two numbers as LinkedList (MEDIUM)
- LC0003 - Longest Substring without repeat (MEDIUM)
- LC0018 - 4-sum-Problem (MEDIUM)
- LC0019 - Remove N-th node from back of LinkedList (MEDIUM)
- LC0021 - Merge two sorted Linked List (use method used in mergeSort) (EASY)
- LC0025 - Reverse a LinkedList in groups of size k (HARD)
- LC0031 - Next Permutation (MEDIUM)
- LC0048 - Rotate Matrix (MEDIUM)
- LC0050 - Pow(X,n) (MEDIUM)
- LC0053 - Kadane’s Algorithm (EASY)
- LC0056 - Merge Overlapping Subintervals (MEDIUM)
- LC0061 - Rotate a LinkedList (MEDIUM)
- LC0062 - Grid Unique Paths (MEDIUM)
- LC0073 - Set Matrix Zeroes (MEDIUM)
- LC0074 - Search in a 2d Matrix (MEDIUM)
- LC0075 - Sort an array of 0’s 1’s 2’s (MEDIUM)
- LC0088 - Merge two sorted Arrays without extra space (EASY)
- LC0118 - Pascal’s Triangle (EASY)
- LC0121 - Stock Buy and Sell (EASY)
- LC0128 - Longest Consecutive Sequence (MEDIUM)
- LC0136 - Single Number (EASY)
- LC0141 - Detect a cycle in Linked List (EASY)
- LC0142 - Find the starting point of the Loop of LinkedList (MEDIUM)
- LC0160 - Find intersection point of Y LinkedList (EASY)
- LC0169 - Majority Element (>N/2 times) (EASY)
- LC0206 - Reverse a LinkedList (EASY)
- LC0217 - Contains Duplicate (EASY)
- LC0229 - Majority Element (>N/3 times) (MEDIUM)
- LC0234 - Check if a LinkedList is palindrome or not (EASY)
- LC0237 - Delete a given Node when a node is given. (0(1) solution) (EASY)
- LC0238 - Product of Array Except Self (MEDIUM)
- LC0268 - Missing Number (EASY)
- LC0287 - Find the duplicate in an array of N+1 integers (MEDIUM)
- LC0442 - Find All Duplicates in an Array (MEDIUM)
- LC0493 - Reverse Pairs (Leetcode) (HARD)
- LC0876 - Find the middle of LinkedList (EASY)
- LC2022 - Convert 1D Array into 2D Array (EASY)
Using the Leetcode Dataset with jq
#
Note
Make sure you install jq, the CLI tool to filter and use JSONs for this section.
I’ve collected all the leetcode questions and metadata into a json which is
placed in the github repo for my blog.
I want to do more with it, but until I do, you should use jq
to filter and
look through it.
I’ll document some commands here.
Getting Questions by Company#
jq '.[] | select(.companyTagStats | strings | ascii_downcase | test("COMPANY_NAME_LOWERCASE") | {id:
.questionId, category: categoryTitle, difficulty, url,
title, tags: [.topicTags[].slug]}' data_sorted.json
Warning
This query will change, since right now, I’m storing companyTagStats
in
its raw text form for now. I want to convert it to a list, but I don’t have
time.
Getting Questions by Category#
jq '.[] | {id: .questionId, title, url, category: .categoryTitle, difficulty,
tags: [.topicTags[].slug]} | select((.category | ascii_downcase) == "CATEGORY_LOWERCASE")' data_sorted.json
Adding New Solutions#
Add an item to problems.toml
and run create_solutions.py
. Do not manually
create solution files.
A problem item in the toml
file is defined as:
[[problems.leetcode]]
name = "2-Sum-Problem"
url = "https://leetcode.com/problems/two-sum/"
number = 1
level = "EASY"
labels = [ "striver", "striver-4",]
Striver List#
This is a rough timeline of problems that follow the Striver SDE Sheet. Note that for now, I’m sticking only to the Leetcode problems linked therein, since I have setup a testing pipeline targetting Leetcode only.
Day 5
- LC0206 - Reverse a LinkedList (EASY)
- LC0876 - Find the middle of LinkedList (EASY)
- LC0021 - Merge two sorted Linked List (use method used in mergeSort) (EASY)
- LC0019 - Remove N-th node from back of LinkedList (MEDIUM)
- LC0002 - Add two numbers as LinkedList (MEDIUM)
- LC0237 - Delete a given Node when a node is given. (0(1) solution) (EASY)
Day 6
- LC0160 - Find intersection point of Y LinkedList (EASY)
- LC0141 - Detect a cycle in Linked List (EASY)
- LC0025 - Reverse a LinkedList in groups of size k (HARD)
- LC0234 - Check if a LinkedList is palindrome or not (EASY)
- LC0142 - Find the starting point of the Loop of LinkedList (MEDIUM)
- LC0061 - Rotate a LinkedList (MEDIUM)
Day 7
Day 8
Day 9
Day 10
Day 11
Day 12
Day 13
Day 14
Day 15
Day 16
Day 17
Day 18
Day 19
Day 20
Day 21
Day 22
Day 23
Day 24
Day 25
Day 26
Day 27
Day 28
Day 29
Day 30
Todo
Add general index since I’ll also be solving problems that are not in the categorized lists.
Perhaps I should just move each of these labelled things to their own toctrees. Panels are overkill if I use them for everything