P#17 Longest Path of a file system

2020. 8. 21. 12:59PS/도전

All problems are from https://www.dailycodingproblem.com/

 

My Solution Codes : https://github.com/Kusin/DailyCoding

 

Kusin/DailyCoding

DailyCodingProblem. Contribute to Kusin/DailyCoding development by creating an account on GitHub.

github.com

Daily Coding Problem#16 Longest Path of a file system

Problem Description

Idea

DP.

1. split the filesystem with '\n'. 

2. count of '\t' implies the level

3. for a directory/file, we only need length of a previous level.

4. update dt[level] for every elem. dt[level] = dt[level-1] + length(file) +1 ('/')

# if elem is root, dt[level] = length(file)

5. update answer if elem is a file.

Implementation

728x90

'PS > 도전' 카테고리의 다른 글

Pause / 일시 중지  (0) 2020.08.26
Problem #18 Sliding Window  (0) 2020.08.23
P#16 The last N elements  (0) 2020.08.21
P#15 Random Element Selection  (0) 2020.08.19
P#14 Calculate Pi by Monte Carlo Method  (0) 2020.08.18