Today, we will solve the 7th problem of the March LeetCoding Challenge.

Problem Statement

Design a HashMap without using any built-in hash table libraries.

To be specific, your design should include these functions:

  • get(key): Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.
  • remove(key) : Remove the mapping for the value key if this map contains the mapping for the key.
MyHashMap hashMap = new MyHashMap();
hashMap.put(1, 1)…


Photo by Daniel Schludi on Unsplash

I know it is hard to get a vaccine slot. I have been trying to get a slot for the last two weeks; still have not got it. Therefore I decided to make a python script that will notify me about the vaccination slots.

For this, we will use the APIs provided by our Indian Government and scrap the page. If you try to do a lot of requests to the server, your IP address may be blocked. BEWARE!!!!!!!!!!!

What is Web Scraping

Web scraping is the process of using bots to extract content and data from a website.

Cowin-API

You can check the APIs…


Today is May the 4th. Happy Star Wars Day everyone.

Let’s solve some Leetcode problems today. Today we will solve the 4th problem of the May LeetCoding Challenge 2021.

Problem Statement

Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.

We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).

Example 1:

Input: nums = [4,2,3]
Output: true
Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
Input: nums = [4,2,1]
Output: false
Explanation: You can't get a non-decreasing array by modify at most one element.

Solution

We are…


Today, we will solve the 3rd problem of the May LeetCoding Challenge 2021.

Problem Statement

Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).

Return the running sum of nums.

Example 1:

Input: nums = [1,2,3,4]
Output: [1,3,6,10]
Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
Input: nums = [1,1,1,1,1]
Output: [1,2,3,4,5]
Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
Input: nums = [3,1,2,10,1]
Output: [3,4,6,16,17]

Solution

This is a pretty easy problem. Here we have to find the running sum of an array. That…


Today, we will solve the 6th problem of the April LeetCoding Challenge 2021.

Problem Statement

You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n).

In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. …


From today, we will start doing the April LeetCoding Challenge. You can check the March LeetCoding Challenge problems on my profile.

Problem Statement

Given the head of a singly linked list, return true if it is a palindrome.

Example 1:


Today we will solve the problem named Authentication Manager.

Problem Statement

There is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will expire timeToLive seconds after the currentTime. If the token is renewed, the expiry time will be extended to expire timeToLive seconds after the (potentially different) currentTime.

Implement the AuthenticationManager class:

  • generate(string tokenId, int currentTime) generates a new token with the given tokenId at the given currentTime in seconds.
  • renew(string tokenId, int currentTime) renews the unexpired token with the given…


Today, we will solve the 19th problem of the March LeetCoding Challenge.

Problem Statement

There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room.

Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length. A key rooms[i][j] = v opens the room with number v.

Initially, all the rooms start locked (except for room 0).

You can walk back and forth between…


Today, we will solve the 18th problem of the March LeetCoding Challenge.

Problem Statement

Given an integer array nums, return the length of the longest wiggle sequence.

A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.

  • In contrast, [1, 4, 7, 2, 5] and…


Today, we will solve the 15th problem of the March LeetCoding Challenge.

Problem Statement

TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk.

Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

Solution

In this problem, we have to design an URL shortening service to encode and decode URLs. Therefore for…

Sourav Saikia

Tech-enthusiastic . Connect me — https://twitter.com/sourav__saikia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store