Normalize a file path
Company: Bridge.Xyz
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Given an absolute Unix-style file path as a string, return its canonical normalized form.
Rules:
- The input always starts with `/`.
- A single `.` means the current directory and should be ignored.
- A double dot `..` means move to the parent directory if possible.
- Multiple consecutive slashes should be treated as a single slash.
- The output must:
- start with exactly one `/`
- contain directory names separated by a single slash
- not end with a trailing slash unless the result is the root path `/`
Example:
- Input: `/a//b/./c/../d/`
- Output: `/a/b/d`
Explain your approach and implement the function.
Quick Answer: This question evaluates string manipulation and parsing skills, specifically understanding Unix-style filesystem path semantics and edge-case normalization.