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 | 701 Views, 22363 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 | 701 Views, 22363 Search Bots | 78 Words Subscribe to Feed Burner

Related Articles

  1. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  2. A trick for getting good at coding interviews FASTER
  3. Spreadsheet Column Title
  4. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  5. Sorting a list with 3 unique numbers
  6. Daily Interview Problem: Reverse Words in a String
  7. Consecutive Ones
  8. Algorithm Interview Question: Nth Fibonacci Number
  9. Daily Interview Puzzle: Minimum Size Subarray Sum
  10. [Daily Problem] Longest Increasing Subsequence

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />