## Find a Path in a Matrix (Java)

Given a 2d matrix, find a path from the top left corner to the bottom right corner. Assume there exists at least one path, and you only need to find…

Given a 2d matrix, find a path from the top left corner to the bottom right corner. Assume there exists at least one path, and you only need to find…

You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array…

Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row number. 1. Naive Method We can…

This post shows how to implement a stack by using an array. The requirements of the stack are: 1) the stack has a constructor which accepts a number to initialize…

There following Java code shows how to implement a queue without using any extra data structures in Java. We can implement a queue by using an array. import java.lang.reflect.Array; import…

Given an n x n matrix where each of the rows and columns is sorted in ascending order, find the kth smallest element in the matrix. Note that it is…

A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1…

You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty…

Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number…

A robot is located at the top-left corner of a m x n grid. It can only move either down or right at any point in time. The robot is…