<commit_before>/**
 * Problem Link: https://leetcode.com/problems/simplify-path/
 *
 * Using stack to implement the path simplify process.
 */

class Solution {
    func simplifyPath(_ path: String) -> String {
        let comp = path.characters.split(separator: "/").map(String.init)
        var ret = [String]()
        for path in comp {
            if path.characters.count == 0 {
                continue
            }
            if path == "." {
                continue
            }
            if path == ".." {
                let _ = ret.popLast()
            } else {
                ret.append(path)
            }
        }
        return "/" + ret.joined(separator: "/")
    }
}
/**
 * https://leetcode.com/problems/simplify-path/
 * 
 * 
 */ 
// Date: Fri Feb  5 09:31:47 PST 2021
class Solution {
    func simplifyPath(_ path: String) -> String {
        let list = path.components(separatedBy: "/")
        var result: [String] = []
        for p in list {
            if p.count > 0 {
                if p == ".." {
                    if result.isEmpty == false {
                        result.removeLast()
                    }
                } else if p == "." {
                    continue
                } else {
                    result.append(p)
                }
            }
        }
        return "/" + result.joined(separator: "/")
    }
}<commit_msg>Add simplify-path.swift<commit_after>/**
 * Problem Link: https://leetcode.com/problems/simplify-path/
 *
 * Using stack to implement the path simplify process.
 */

class Solution {
    func simplifyPath(_ path: String) -> String {
        let comp = path.characters.split(separator: "/").map(String.init)
        var ret = [String]()
        for path in comp {
            if path.characters.count == 0 {
                continue
            }
            if path == "." {
                continue
            }
            if path == ".." {
                let _ = ret.popLast()
            } else {
                ret.append(path)
            }
        }
        return "/" + ret.joined(separator: "/")
    }
}
/**
 * https://leetcode.com/problems/simplify-path/
 * 
 * 
 */ 
// Date: Fri Feb  5 09:31:47 PST 2021
class Solution {
    func simplifyPath(_ path: String) -> String {
        let list = path.components(separatedBy: "/")
        var result: [String] = []
        for p in list {
            if p.count > 0 {
                if p == ".." {
                    if result.isEmpty == false {
                        result.removeLast()
                    }
                } else if p == "." {
                    continue
                } else {
                    result.append(p)
                }
            }
        }
        return "/" + result.joined(separator: "/")
    }
}/**
 * https://leetcode.com/problems/simplify-path/
 * 
 * 
 */ 
// Date: Fri Feb  5 09:41:26 PST 2021
class Solution {
    func simplifyPath(_ path: String) -> String {
        var text = ""
        var result : [String] = []
        for c in path + "/" {
            let cString = String(c)
            if c == "/" {
                if text.count > 0 {
                    if text == "." {
                        // do nothing
                    } else if text == ".." {
                        if result.isEmpty == false {
                            result.removeLast()
                        }
                    } else {
                        result.append(text)
                    }
                    text = ""
                }
            } else {
                text.append(c)
            }
        }
        return "/" + result.joined(separator: "/")
    }
}
{'fraction_non_alphanumeric': 0.1281002998092123, 'fraction_numerical': 0.010357045516489506, 'mean_word_length': 1.0287451630735214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6167987', 'n_tokens_mistral': 1077, 'n_tokens_neox': 958, 'n_words': 225}