Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sensor Data Processing and Path Optimization

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Sensor Data Processing and Path Optimization. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Implement a function to process sensor data or optimize a search path.

For this exercise, use the search-path interpretation. Given a rectangular grid, find the shortest path from start to goal, moving only up, down, left, or right through passable cells. Return the path as a list of coordinates, or an empty list when no path exists.

Input and Output

grid is a 2D list where 0 is passable and 1 is blocked. start and goal are [row, column] coordinates. Return coordinates in order from start to goal. Both endpoints are passable.

Constraints

  • 1 <= len(grid) <= 200
  • 1 <= len(grid[0]) <= 200
  • All rows have the same length
  • len(grid) * len(grid[0]) <= 100000
  • Each grid value is either 0 or 1
  • start and goal are valid passable coordinates

Function Signature

def optimize_search_path(grid, start, goal):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output