I am trying Find the phone numbers of all managers whose direct report hierarchy live in more than 1 city in O(n) time complexity. Below is my approach which is using with Time Complexity O(M*N) where M is the number of managers and N is the Number of employess. Can someone please help me with O(N) solution for this problem.
Tag: breadth-first-search
How to output direction of shortest path?
This is a simple maze solver program. this is the simple maze i’m working on. I implemented a solution to output cordinates of the path as follow.(cordinates aquired from a BFS algorithm) but I want to output like below(omit same direction and only output direction and last coordinate to same direction), this all coordinates are allocated to a stack.below is
Find Number of steps needed to traverse from one top left to bottom right in a matrix
in Matrix A with 6 rows and 4 columns. where ‘#’ = blocked path and ‘.’ = allowed path.. How to find the number of steps needed to reach from top left to bottom left.I am able to traverse the matrix from top left to bottom right but unable to find the steps(which is 8 here)..But the code below I