To the Top
File:  root - text - article - 2020 - 02 - absolute-path.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 628 Views, 19685 Search Bots | 78 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:

Given a file path with folder names, '..' (Parent directory), and '.' (Current directory), return the shortest possible file path (Eliminate all the '..' and '.').

Example
Input: '/Users/Joma/Documents/../Desktop/./../'
Output: '/Users/Joma/'

def shortest_path(file_path):
# Fill this in.

print shortest_path('/Users/Joma/Documents/../Desktop/./../')
# /Users/Joma/
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 628 Views, 19685 Search Bots | 78 Words Subscribe to Feed Burner

Related Articles

  1. Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
  2. Staying on a Chess Board
  3. Windows Scripting
  4. Daily Interview Problem: Circle of Chained Words
  5. 56 Bytes
  6. [Daily Problem] Longest Palindromic Substring
  7. Daily Interview Problem: Min Range Needed to Sort
  8. Daily Interview Problem: Merge Overlapping Intervals
  9. [Daily Problem] Remove k-th Last Element From Linked List
  10. Algorithm Interview: Shifted String

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />