First round
Our website supports creating a 2D grid of videos we call wall, where each video in it is a tile. Before saving a wall, we must validate it.
The client sends a list of tiles, where each tile encodes its 2D coordinate(s) (x,y) inside the wall as integers. The wall can only include 1x1 fixed sized tiles, the coordinates pair identifies the starting corners of the tile in this case. An example follows (the notation is intended to be language agnostic, it is incidentally the same as python):
[[0,0],[0,1],[1,0],[1,1]]
Which means:
(0,0) to (1,1);(0,1) to (1,2);(1,0) to (2,1);(1,1) to (2,2);Write a function that validates a wall with only 1x1 tiles. You can assume all coordinates are >= 0.
A wall is valid if:
[0,0] with no holes;The function returns true if the wall is valid, false otherwise.
Note: you can model the wall and tiles as you wish.
Example of a valid wall: [[0,0],[0,1],[1,0],[1,1]]
Example of a valid wall: [[1,1],[0,1],[0,0],[1,0]]
Example of a valid wall: [[0,0],[0,1]]
Example of an invalid wall (containing holes): [[0,0],[1,1]]
Example of an invalid wall (containing holes): [[0,0],[0,1],[1,0]]
Example of an invalid wall (overlapping tiles): [[0,0],[0,1],[0,1],[1,1]]
Design Interview - Detection Events
Full Stack Role
Context (for you to understand what we are talking about)
Our cameras run some fancy AI detection algorithm which produces outputs with the following fields:
Field Name Field type Description
Camera hash string Unique hash of the camera
Detection type enum Person,car,bicycle
startX float Bounding box coordinate
startY float Bounding box coordinate
endX float Bounding box coordinate
endY float Bounding box coordinate
timestamp int/string (you choose) Time of this event
These events are then batched (e.g. every second) and pushed out.
You can assume we already store the camera information and they are available in your backend. Last seen time is periodically updated. It is not related to the pushed events:
Field Name Field type Description
Camera hash string Unique hash of the camera
Camera name string Chosen by the user
Last seen time time When the camera was last seen
System components (this is the stuff you should design)
Backend
Design a backend architecture to process the data coming from the cameras.
Detections should be stored persistently. You should consider the following:
Frontend Pages
Design the following 2 user pages:
Landing page
This page lists all the cameras in the system. For each camera we want to show whether it is online or not (online is last_seen_time < 30 s from now). Cameras can change over time (some might be removed/added). The user can click on a camera to be taken to the daily activity page.
Camera Daily activity page
This page gives information about detection events for a single camera and a single day of choice. A user should be able to answer the following questions:
Think about how to best display this information.