Skip to content

Instantly share code, notes, and snippets.

View sushinoya's full-sized avatar
🐢

Suyash Shekhar sushinoya

🐢
View GitHub Profile

Leetcode Problems Sorted By Popularity

Leetcode does not allow sorting problems by upvotes/downvotes. That is probably to encourage users to attempt newer problems. However, for someone with limited preparation time, going through the most popular questions first might be helpful. Hence, here is a list of Leetcode questions sorted by popularity. The data are accurate as of 13th July 2021. [Raw Markdown]

Rank Problem Difficulty Upvotes Downvotes
1 1. Two Sum Easy 22445 760
2 [3. Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-wi
@sushinoya
sushinoya / fetch_tweet.py
Last active November 4, 2020 18:35
Fetch Tweet by Tweet ID
from bs4 import BeautifulSoup, NavigableString
from urllib.request import urlopen, Request
def fetch_tweet(tweet_id):
url = f"https://twitter.com/anyuser/status/{tweet_id}"
agent = "Mozilla/5.0 (compatible; MSIE 7.01; Windows NT 5.0)"
try:
html_response = urlopen(Request(url, headers={'User-Agent': agent}))
from pandas import read_csv
from pandas import DataFrame
from pandas import Grouper
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
DATES_FASTED_ON = {"16/4/2020", "17/4/2020", "18/4/2020", "19/4/2020", "20/4/2020", "21/4/2020", "22/4/2020", "8/5/2020", "9/5/2020", "10/5/2020",
"11/5/2020", "18/5/2020", "22/5/2020", "23/5/2020", "24/5/2020", "25/5/2020", "26/5/2020", "27/5/2020", "28/5/2020", "5/6/2020", "6/6/2020",}
{"lastUpload":"2020-05-13T05:50:26.752Z","extensionVersion":"v3.4.3"}
@sushinoya
sushinoya / 3Sum.py
Created June 26, 2019 02:13
3Sum using a dictionary
class Solution:
def threeSum(self, nums):
if all(map(lambda x: x == 0, nums)):
if len(nums) >= 3:
return [[0,0,0]]
else:
return []
positives = [x for x in nums if x > 0]
negatives = [x for x in nums if x <= 0]

Keybase proof

I hereby claim:

  • I am sushinoya on github.
  • I am sushinoya (https://keybase.io/sushinoya) on keybase.
  • I have a public key ASAoe-PNsbzGS3bP0meHjdUG_QNyaxWIfDt0gYqxWJnw1Ao

To claim this, I am signing this object:

@sushinoya
sushinoya / FollowRequest.rb
Last active December 11, 2017 15:16
Twitter Clone Code
class FollowRequest < ActiveRecord::Base
belongs_to :sender, class_name: 'User'
belongs_to :recipient, class_name: 'User'
enum status: [:pending, :accepted, :rejected]
scope :sent_unaccepted, -> { where(status: [statuses[:pending], statuses[:rejected]]) }
validates :sender, presence: true, uniqueness: { scope: [:recipient_id] }
validates :recipient, presence: true