Today, we will solve the 7th problem of the March LeetCoding Challenge.
Design a HashMap without using any built-in hash table libraries.
To be specific, your design should include these functions:
put(key, value): Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value.
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();
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!!!!!!!!!!!
Web scraping is the process of using bots to extract content and data from a website.
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.
nintegers, 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).
Input: nums = [4,2,3]
Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
Input: nums = [4,2,1]
Explanation: You can't get a non-decreasing array by modify at most one element.
Today, we will solve the 3rd problem of the May LeetCoding Challenge 2021.
Given an array
nums. We define a running sum of an array as
runningSum[i] = sum(nums…nums[i]).
Return the running sum of
Input: nums = [1,2,3,4]
Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
Input: nums = [1,1,1,1,1]
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]
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.
You have an array
arr of length
arr[i] = (2 * i) + 1 for all valid values of
0 <= i < n).
In one operation, you can select two indices
0 <= x, y < n and subtract
arr[x] and add
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.
head of a singly linked list, return
true if it is a palindrome.
Today we will solve the problem named Authentication Manager.
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)
AuthenticationManager(int timeToLive)constructs the
AuthenticationManagerand sets the
generate(string tokenId, int currentTime)generates a new token with the given
tokenIdat the given
renew(string tokenId, int currentTime)renews the unexpired token with the given…
Today, we will solve the 19th problem of the March LeetCoding Challenge.
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
Initially, all the rooms start locked (except for room
You can walk back and forth between…
Today, we will solve the 18th problem of the March LeetCoding Challenge.
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.
[1, 7, 4, 9, 2, 5]is a wiggle sequence because the differences
(6, -3, 5, -7, 3)are alternately positive and negative.
[1, 4, 7, 2, 5]and…
Today, we will solve the 15th problem of the March LeetCoding Challenge.
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.
In this problem, we have to design an URL shortening service to encode and decode URLs. Therefore for…