Company: Toast_24nov
Difficulty: medium
Waiter's Path Problem Description A restaurant has a long row of n tables, each spaced differently along a hallway. A waiter needs to deliver meals from the kitchen to the last table in the row. The waiter can only step from one table to another—stepping onto the floor between tables is not allowed. The waiter starts at the first table. The first step, from the first to the second table, must be exactly 1 unit. For every subsequent step, if the last step was k units, the next step must be either k-1, k, or k+1 units. The waiter can only move forward along the row. Given the positions of the tables, determine if the waiter can successfully reach the last table in the hallway following these stepping rules. Examples Example 1: Input: tables = [0, 1, 2, 4, 5] Output: true Explanation: - Step from table 1 (pos 0) to table 2 (pos 1): step size = 1. Last step k = 1. - Step from table 2 (pos 1) to table 3 (pos 2): step size = 1. Valid since 1 is in {k-1, k, k+1} = {0, 1, 2}. Last step k = 1.