Ashish Thakurashisht.hashnode.dev·May 19, 2024Understanding Java ArrayList in Collections// Dynamic array -- ArrayList: // 1: The size is dynamic. // 2: It allows duplicates. // 3: Storing null is permissible. // 4: It enables random access to elements due to index-based storage. // 5: ArrayList is...DiscussJava
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Row With Maximum OnesGiven a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row. In case there are multiple rows that have the maximum count of ones, the row with the smallest row nu...DiscussJava Solutionarray
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Calculate Delayed Arrival TimeYou are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours. Return the time when the train will arrive at the station. Note that the time ...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Check if Grid Satisfies ConditionsYou are given a 2D matrix grid of size m x n. You need to check if each cell grid[i][j] is: Equal to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists). Different from the cell to its right, i.e. grid[i][j] != grid[i][j + 1] (if it...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Rotate ImageYou are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotat...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Largest Local Values in a MatrixYou are given an n x n integer matrix grid. Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that: maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1. In other words...DiscussJava SolutionJava
Rohit Dasublogs.rohitdasu.dev·May 13, 2024The most confusing array methodReduce() is not just another array method; it's more than that. Do you think I'm exaggerating? No, I'm not. Keep reading below to find out why. This array method requires two arguments: Callback function This callback function is invoked with the f...Discuss·10 likes·42 readsarray
Tapan Rachchhtapanrachchh.hashnode.dev·May 14, 20241219. Path with Maximum Goldclass Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) ans = 0 def travel(x, y, gold, visited): nonlocal ans if x >= 0 and y >= 0 and x < m and y < ...DiscussPython
Koustav Hazrakoustavhazra.hashnode.dev·May 13, 2024Leetcode 118. Pascal's TriangleDescription: Pascal's Triangle is a mathematical concept that is represented as a triangular array of binomial coefficients. Each number in the triangle is the sum of the two directly above it. The first and last numbers in each row are always 1. Var...Discussleetcode
Koustav Hazrakoustavhazra.hashnode.dev·May 12, 2024Leetcode 73. Set Matrix ZeroDescription: Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. You must do it in place. Example: Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]] Constraints: m == matrix.lengt...DiscussStriverSDESheet