<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Solution : <EOL> def convertToPN ( self , expression ) : <EOL> """<STR_LIT>""" <EOL> return self . infix2prefix ( expression ) <EOL> def infix2prefix ( self , lst ) : <EOL> """<STR_LIT>""" <EOL> stk = [ ] <EOL> pre = [ ] <EOL> for elt in reversed ( lst ) : <EOL> if elt . isdigit ( ) : <EOL> pre . append ( elt ) <EOL> elif elt == "<STR_LIT:)>" : <EOL> stk . append ( elt ) <EOL> elif elt == "<STR_LIT:(>" : <EOL> while stk and stk [ - <NUM_LIT:1> ] != "<STR_LIT:)>" : <EOL> pre . append ( stk . pop ( ) ) <EOL> stk . pop ( ) <EOL> else : <EOL> while stk and self . precedence ( elt ) < self . precedence ( stk [ - <NUM_LIT:1> ] ) : <EOL> pre . append ( stk . pop ( ) ) <EOL> stk . append ( elt ) <EOL> while stk : <EOL> pre . append ( stk . pop ( ) ) <EOL> pre . reverse ( ) <EOL> return pre <EOL> def precedence ( self , x ) : <EOL> if x in ( "<STR_LIT:(>" , "<STR_LIT:)>" ) : <EOL> return <NUM_LIT:0> <EOL> if x in ( "<STR_LIT:+>" , "<STR_LIT:->" ) : <EOL> return <NUM_LIT:1> <EOL> if x in ( "<STR_LIT:*>" , "<STR_LIT:/>" ) : <EOL> return <NUM_LIT:2> <EOL> return <NUM_LIT:3> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> assert Solution ( ) . infix2prefix ( [ "<STR_LIT:(>" , "<STR_LIT:5>" , "<STR_LIT:->" , "<STR_LIT>" , "<STR_LIT:)>" , "<STR_LIT:*>" , "<STR_LIT>" ] ) == [ '<STR_LIT:*>' , '<STR_LIT:->' , '<STR_LIT:5>' , '<STR_LIT>' , '<STR_LIT>' ] </s>
