human
Simplify the directory path ( Unix like ) | function to simplify a Unix - styled absolute path.
using vector in place of stack.
forming the current directory ..
if " . . " , we pop ..
do nothing ( added for better understanding . ).
push the current directory into the vector ..
forming the ans.
vector is empty.
absolute path which we have to simplify ."
Solution in Python:

Can you provide a code to simplify the directory path ( Unix like ) and the other steps required?
assistant
#Here is code to simplify the directory path ( Unix like ) and the other steps required.
 def simplify ( path ) :
	v = [ ]
	n = len ( path )
	ans = " "
	for i in range ( n ) :
		Dir = " "
		while ( i < n and path [ i ] != ' / ' ) :
			Dir += path [ i ]
			i += 1
		if ( Dir == " . . " ) :
			if ( len ( v ) > 0 ) :
				v . pop ( )
		elif ( Dir == " . " or Dir == " " ) :
			continue
		else :
			v . append ( Dir )
	for i in v :
		ans += " / " + i
	if ( ans == " " ) :
		return " / "
	return ans
Str = " / a / . / b / . . / . . / c / "
res = simplify ( Str )
print ( res )