https://leetcode.com/problems/simplify-path/description/
第一次拿第一,开心
/**
* @param {string} path
* @return {string}
*/
var simplifyPath = function(path) {
arr=path.split('/');
arr1=[];
for(var i=0;i<arr.length;i++){
switch (arr[i]){
case '':
break;
case '.':
break;
case '..':
if(arr1.length>0){
arr1.pop();
}
break;
case '/':
break;
default:
arr1.push(arr[i]);
}
}
return "/"+arr1.join("/");
};