Open in app
Home
Notifications
Lists
Stories

Write
Amarjit Dhillon
Amarjit Dhillon

Home

Feb 12

Range Addition II

Problem Statement You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < bi. Count and return the number of…

Leetcode

2 min read

Range Addition II
Range Addition II

Feb 12

How to perform range addition in O(n) time and O(1) space complexity?

Problem Statement You are given an integer length and an array updates where updates[i] = [startIdxi, endIdxi, inci]. You have an array arr of length length with all zeros, and you have some operation to apply on arr. In the ith operation, you should increment all the elements arr[startIdxi], arr[startIdxi + 1]…

Coding

2 min read

How to perform range addition in O(n) time and O(1) space complexity?
How to perform range addition in O(n) time and O(1) space complexity?

Feb 12

Coin Change

Problem Statement You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. …

Coding

2 min read

Coin Change
Coin Change

Feb 11

Count the number of islands 🏝

Problem Statement Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. …

Leetcode

3 min read

Count the number of islands 🏝
Count the number of islands 🏝

Feb 11

Merge Intervals

Problem Statement Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example…

Coding

2 min read

Merge Intervals
Merge Intervals

Feb 11

Find the kth factor of n

Problem Statement You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0. Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if…

Coding

2 min read

Find the kth factor of n
Find the kth factor of n

Feb 11

Analyze User Website Visit Pattern

This is a Leetcode question which can be found here Problem statement: You are given two string arrays username and website and an integer array timestamp. All the given arrays are of the same length and the tuple [username[i], website[i], timestamp[i]] indicates that the user username[i] visited the website website[i] at time…

Coding

4 min read

Analyze User Website Visit Pattern
Analyze User Website Visit Pattern

Feb 10

Design Parking System

Problem Statement ❓ Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the ParkingSystem class: ParkingSystem(int big, int medium, int small) Initializes the object of the ParkingSystem class. The number of…

Coding

2 min read

Design Parking System
Design Parking System

Feb 10

Word Pattern

Problem Statement Given a pattern and a string s, find if s follows the same pattern. Issue link: https://leetcode.com/problems/word-pattern/ Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Example 1: Input: pattern = "abba", s = "dog cat…

Coding

3 min read

Word Pattern
Word Pattern

Feb 9

Count Binary Substrings

Problem statement Problem link: Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the number of times they occur. Example…

Coding

3 min read

Count Binary Substrings
Count Binary Substrings
Amarjit Dhillon

Amarjit Dhillon

Solution Architect @ Air Canada

Following
  • Manning Publications

    Manning Publications

  • Abhijit Mondal

    Abhijit Mondal

  • Michael Galarnyk

    Michael Galarnyk

  • Julia Kho

    Julia Kho

  • Aryannayakk

    Aryannayakk

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable