logo

BLOGS IN DSA

  •  2022-07-20
    Swim in Rising Water

    The rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most t. You can swim infinite distances in zero time ...

    Read  

    Sumit Kumar

  •  2022-06-15
    Find The Celebrity

    Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know him/her but he/she does not know any of them. There will be exactly one celebrity if he/she is in the party ...

    Read  

    Sumit Kumar

  •  2022-05-15
    Max Points In Archery

    Alice and Bob are opponents in an archery competition. Alice first shoots numArrows arrows and then Bob shoots numArrows arrows. Return the array bobArrows which represents the number of arrows Bob shot on each scoring section from 0 to 11. The sum of the values in bobArrows should equal numArrows ...

    Read  

    Sumit Kumar

  •  2022-04-28
    Copy List with Random Pointer

    A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. Construct a deep copy of the list . The deep copy should consist of exactly n brand new nodes. This solution use no extra space ...

    Read  

    Sumit Kumar

  •  2022-04-15
    Remove Duplicate Letters

    Given a string s where s consists of lowercase English letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results . We will solve this problem in linear runtime and with constant space ...

    Read  

    Sumit Kumar

  •  2022-02-27
    Assured Destruction

    UN Spy satellite Watchtower-14 has detected martian stealth ballistic missile platforms. Earth has decided to launch a pre-emptive strike to destroy those platforms and eliminate the MCR's first strike capability. The only defence against these beasts is our planetary railgun. Our Railgun once fully charged, can eliminate a single planet buster. However, our railgun takes one minute to charge for firing ...

    Read  

    Sumit Kumar

  •  2021-12-23
    Cherry Pickup

    Given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.You have two robots that can collect cherries for you ...

    Read  

    Sumit Kumar

  •  2021-12-09
    Jump Game

    Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach to any index with value 0. Notice that you can not jump outside of the array at any time. We will solve this problem using BFS ...

    Read  

    Sumit Kumar

  •  2021-11-25
    Interval List Intersections

    You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order...

    Read  

    Sumit Kumar

  • PREMIUM
     2021-11-23
    Largest Component Size by Common Factor

    A disjoint-set data structure is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets...

    Read  

    Sumit Kumar

  •  2021-11-18
    Pacific Atlantic Water Flow

    There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges...

    Read  

    Sumit Kumar

  •  2021-11-16
    Snakes and Ladder

    You are given an n x n integer matrix board where the cells are labeled from 1 to n^2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) and alternating direction each row....

    Read  

    Sumit Kumar

  •  2021-11-15
    Knight Probability in Chess Board

    On an n x n chessboard, a knight starts at the cell (row, column) and attempts to make exactly k moves. The rows and columns are 0-indexed....

    Read  

    Sumit Kumar

  •  2021-11-14
    N Queens

    The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other...

    Read  

    Sumit Kumar

  •  2021-11-13
    Daily Temperatures

    Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature....

    Read  

    Sumit Kumar

  •  2021-11-13
    Paint House

    There are a row of n houses, each house can be painted with one of the three colors-- red, blue or green. The cost of painting each house with a certain color is different....

    Read  

    Sumit Kumar

  • PREMIUM
     2021-11-13
    Super Egg Drop

    Super Egg Drop problem is decribed in the Wikipedia's article for Dynamic Programming.Lets look at how we solve this problem using memoization and binary search .The code for this is written in JavaScript ...

    Read  

    Sumit Kumar

  •  2021-11-12
    Number of Valid Words for Each Puzzle

    The primary challenge in this problem is determining an efficient way to find the number of valid words for each puzzle. To achieve this, we need to somehow put the words into a data structure that allows us to perform a quick search ...

    Read  

    Sumit Kumar

  • FEATURED
     2021-11-10
    Aggressive Cows

    Aggressive Cows is based on the concept, Binary Search . In this question we have to maximize the minimum gap between two aggressive cows. The code for this is written in JavaScript ...

    Read  

    Sumit Kumar

  •  2021-11-10
    Burst Balloons

    We are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. We are asked to burst all the balloons....

    Read  

    Sumit Kumar

  • FEATURED
     2021-11-10
    Making A Large Island

    Making A Large Island is a spin off of popular Number of Island problem . In this problem we would be using DFS. The code for this is written in JavaScript ...

    Read  

    Sumit Kumar

  •  2021-11-08
    House Robber

    The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root...

    Read  

    Sumit Kumar

  •  2021-06-28
    Trapping Rainwater

    Trapping Rainwater is one of my favorite question in DSA . In this post , I will be covering the steps required to reach the optimal solution . The code for this is written in JavaScript ...

    Read  

    Sumit Kumar

  • Blog Categories

    • JavaScript  
    • Performance  
    • DSA  
    • Database  
    • Security  
    • Backend  

    Exclusive Blogging Rights @codered_jack
    Loading...