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.

Leetcode Problems

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 Tags#

jq '.[] | {id: .questionId, title, url, category: .categoryTitle, difficulty,
tags: [.topicTags[].slug]} | select(.tags[] | ascii_downcase | contains("TAG_NAME_LOWERCASE"))' data_sorted.json

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 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