摘要:
用栈的结构就能很好的实现,贴代码 1 class Solution { 2 public: 3 int evalRPN(vector<string>& tokens) 4 { 5 stack<int> st; 6 int n = tokens.size(); 7 for(int i = 0 ; i 阅读全文
摘要:
用位运算来实现该问题,用异或可以实现无符号的加法操作,然后需要使用与运算来实现进位,而负数因为是补码的形式存储所以能够得到正确的处理,十分巧妙的方法,贴代码。 1 class Solution { 2 public: 3 int getSum(int a, int b) 4 { 5 while(b! 阅读全文