码迷,mamicode.com
首页 >  
搜索关键字:simplifypath    ( 9个结果
LeetCode71. 简化路径
☆☆思路:使用字符串的split方法,以'/'为分隔符区分字符,然后逐步识别符号'..'与字母,'.'可以直接忽略,还需要注意空的情况。 class Solution { public String simplifyPath(String path) { // 需要注意连着的// 分出来是空 Str ...
分类:其他好文   时间:2020-12-23 12:19:58    阅读次数:0
lc 简化路径
链接:https://leetcode-cn.com/explore/interview/card/bytedance/242/string/1013/ 代码: #include <stack> class Solution { public: string simplifyPath(string ...
分类:其他好文   时间:2020-05-18 00:23:56    阅读次数:56
# simplifyPath
```js /** * @param {string} path * @return {string} */ function simplifyPath(path) { const pathArr = path.split('/').filter(item => item !== ''); cons... ...
分类:其他好文   时间:2019-05-31 13:22:00    阅读次数:73
Leetcode 之Simplify Path(36)
主要看//之间的内容:如果是仍是/,或者是.,则忽略;如果是..,则弹出;否则压入堆栈。最后根据堆栈的内容进行输出。 string simplifyPath(string const& path) { vector<string> dirs; for (auto i = path.begin(); ...
分类:其他好文   时间:2016-05-26 10:11:06    阅读次数:130
[LeetCode]Simplify Path
public class Solution { public String simplifyPath(String path) { String[] strs = path.split("/"); Stack stack = new Stack(); ...
分类:其他好文   时间:2015-12-06 09:55:06    阅读次数:158
071 Simplify Path
071 Simplify Path有了split,天下我有class Solution: # @param {string} path # @return {string} def simplifyPath(self, path): stack = [] ...
分类:其他好文   时间:2015-07-20 15:58:56    阅读次数:92
LeetCode71 Simplify Path java题解
题目: Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" 题解: 解题思路:这题是简化目录,每一级目录前面都有一个斜杠,我可以首先对斜杠进行分割,分割之后...
分类:编程语言   时间:2015-07-01 10:10:26    阅读次数:150
Leetcode# 71 Simplify Path
原题地址用栈保存化简后的路径。把原始路径根据"/"切分成若干小段,然后依次遍历若当前小段是"..",弹栈若当前小段是".",什么也不做否则,入栈代码: 1 string simplifyPath(string path) { 2 vector buffer; 3 char *tok = NU...
分类:其他好文   时间:2015-01-25 18:09:35    阅读次数:138
LeetCode Simplify Path
class Solution {public: string simplifyPath(string path) { int len = path.length(); if (len spath; int p = -1, q = 0; ...
分类:其他好文   时间:2014-06-04 20:15:49    阅读次数:197
9条  
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!