PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Bridge.Xyz

Normalize a file path

Last updated: Apr 2, 2026

Quick Overview

This question evaluates string manipulation and parsing skills, specifically understanding Unix-style filesystem path semantics and edge-case normalization.

  • medium
  • Bridge.Xyz
  • Coding & Algorithms
  • Software Engineer

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.

Bridge.Xyz logo
Bridge.Xyz
Jan 27, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0

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.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bridge.Xyz•More Software Engineer•Bridge.Xyz Software Engineer•Bridge.Xyz Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.