LeetCode 224 - Basic Calculator


LeetCode 227 - Basic Calculator II
LeetCode – Basic Calculator (Java)
Implement a basic calculator to evaluate a simple expression string.
The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces.You may assume that the given expression is always valid.
Some examples: "1 + 1" = 2, "(1)" = 1, "(1-(4-5))" = 2
1. Use stack: opStack && numStack
CHECK this: https://github.com/eryueniaobp/leetcode/blob/master/string%20algorithm/Calculator.cpp
X. Using one stack
https://www.cnblogs.com/grandyang/p/4570699.html
这道题让我们实现一个基本的计算器来计算简单的算数表达式,而且题目限制了表达式中只有加减号,数字,括号和空格,没有乘除,那么就没啥计算的优先级之分了。于是这道题就变的没有那么复杂了。我们需要一个栈来辅助计算,用个变量sign来表示当前的符号,我们遍历给定的字符串s,如果遇到了数字,由于可能是个多位数,所以我们要用while循环把之后的数字都读进来,然后用sign*num来更新结果res;如果遇到了加号,则sign赋为1,如果遇到了符号,则赋为-1;如果遇到了左括号,则把当前结果res和符号sign压入栈,res重置为0,sign重置为1;如果遇到了右括号,结果res乘以栈顶的符号,栈顶元素出栈,结果res加上栈顶的数字,栈顶元素出栈
https://discuss.leetcode.com/topic/33044/java-easy-version-to-understand

https://discuss.leetcode.com/topic/15816/iterative-java-solution-with-stack
Simple iterative solution by identifying characters one by one. One important thing is that the input is valid, which means the parentheses are always paired and in order.
Only 5 possible input we need to pay attention:
  1. digit: it should be one digit from the current number
  2. '+': number is over, we can add the previous number and start a new number
  3. '-': same as above
  4. '(': push the previous result and the sign into the stack, set result to 0, just calculate the new result within the parenthesis.
  5. ')': pop out the top two numbers from stack, first one is the sign before this pair of parenthesis, second is the temporary result before this pair of parenthesis. We add them together.
Finally if there is only one number, from the above solution, we haven't add the number to the result, so we do a check see if the number is zero.
public int calculate(String s) {
    Stack<Integer> stack = new Stack<Integer>();
    int result = 0;
    int number = 0;
    int sign = 1;
    for(int i = 0; i < s.length(); i++){
        char c = s.charAt(i);
        if(Character.isDigit(c)){
            number = 10 * number + (int)(c - '0');
        }else if(c == '+'){
            result += sign * number;
            number = 0;
            sign = 1;
        }else if(c == '-'){
            result += sign * number;
            number = 0;
            sign = -1;
        }else if(c == '('){
            //we push the result first, then sign;
            stack.push(result);
            stack.push(sign);
            //reset the sign and result for the value in the parenthesis
            sign = 1;   
            result = 0;
        }else if(c == ')'){
            result += sign * number;  
            number = 0;
            result *= stack.pop();    //stack.pop() is the sign before the parenthesis
            result += stack.pop();   //stack.pop() now is the result calculated before the parenthesis
            
        }
    }
    if(number != 0) result += sign * number;
    return result;
}
http://www.cnblogs.com/grandyang/p/4570699.html
我们需要一个栈来辅助计算,用个变量sign来表示当前的符号,我们遍历给定的字符串s,如果遇到了数字,由于可能是个多位数,所以我们要用while循环把之后的数字都读进来,然后用sign*num来更新结果res;如果遇到了加号,则sign赋为1,如果遇到了符号,则赋为-1;如果遇到了左括号,则把当前结果res和符号sign压入栈,res重置为0,sign重置为1;如果遇到了右括号,结果res乘以栈顶的符号,栈顶元素出栈,结果res加上栈顶的数字,栈顶元素出栈
http://www.wengweitao.com/leetcode-basic-calculator.html
如果当前字符c是数字字符,数字可能不止一位,所以需要继续遍历下一个字符,若仍然是数字字符,将其与前面的连续数字字符组成一个数num,直到遇到下一个非数字字符;
如果当前的字符c是'+',那么就将前面的num加到result中,并且设置符号标记sign=1为正;
如果当前字符c是'-',那么就用result - num,并且设置符号标记sign=-1为负;
如果当前字符c是'(',那么先保存当前的result和符号sign到栈中,再继续计算括号里面的表达式;
如果当前字符c是')',那么计算完毕当前括号的result后,依次弹出栈顶的sign和result,然后将括号中的result和栈顶弹出的result相加(或相减,由sign决定);
继续以上步骤,直到遍历到字符串的最后一个字符

下面这种方法和上面的基本一样,只不过对于数字的处理略微不同,上面的方法是连续读入数字,而这种方法是使用了一个变量来保存读入的num,所以在遇到其他字符的时候,都要用sign*num来更新结果res
http://shibaili.blogspot.com/2015/06/day-112-count-complete-tree-nodes.html
用初始化 sign = 1来处理符号,能解决特殊情况. 对()的处理 
    int calculate(string s) {
        stack<int> st;
        int sign = 1;
        int rt = 0;
        int num = 0;
         
        for (int i = 0; i < s.length(); i++) {
            if (isdigit(s[i])) {
                num = num * 10 + s[i] - '0';
            }else if (s[i] == '+') {
                rt += sign * num;
                sign = 1;
                num = 0;
            }else if (s[i] == '-') {
                rt += sign * num;
                sign = -1;
                num = 0;
            }else if (s[i] == '(') {
                st.push(rt);
                st.push(sign);
                sign = 1;
                rt = 0;
            }else if (s[i] == ')') {
                rt += num * sign;
                sign = st.top();
                st.pop();
                rt = sign * rt + st.top();
                st.pop();
                num = 0;
            }
        }
         
        if (num != 0) {
            return rt + sign * num;
        }
         
        return rt;
    }
http://www.cnblogs.com/tonix/p/4563300.html

X.  Only use stack to store the sign info (1 or -1) when meet ‘(‘ or ‘)’
这道题让我们实现一个基本的计算器来计算简单的算数表达式,而且题目限制了表达式中只有加减号,数字,括号和空格,没有乘除,那么就没啥计算的优先级之分了。于是这道题就变的没有那么复杂了。我们需要一个一维的符号数组来记录加减号,然后我们开始遍历字符串表达式,如果遇到的是数字,则从符号数组中取出最后一个符合和数字运算后更新结果,如果遇到右括号,则移除一个符号,如果遇到的不是空格,即有可能是加减号或是左括号,则符号数组中加1或-1,做个判断,如果是负号,加个-1,其他情况加1。代码如下:
public int calculate2(String s) {
    Stack<Integer> stack = new Stack<Integer>();
    stack.push(1);
    int res = 0;
    int sign = 1;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (c == '+' || c == '-') {
            sign = c == '+' ? 1: -1;
        } else if (c == '(') {
            stack.push(sign * stack.peek());
            sign = 1;
        } else if (c == ')') {
            sign = stack.pop();
        } else if (Character.isDigit(c)) {
            int num = 0;
            while (i < s.length() && Character.isDigit(s.charAt(i))) {
                num = num * 10 + (s.charAt(i) - '0');
                i++;
            }
            i--;
            res += sign * num * stack.peek();
        }
    }
    return res;
}
https://leijiangcoding.wordpress.com/2015/06/08/leetcode-q224-basic-calculator/
    public int calculate(String s) {
        Stack<Integer> numbers = new Stack<Integer>();
        int num = 0, res = 0, sign = 1;
        for (int i = 0; i < s.length(); i++){
            if (Character.isDigit(s.charAt(i))){
                num = num * 10 + s.charAt(i) - '0';
            }else if (s.charAt(i) == '+' || s.charAt(i) == '-'){
                res += num * sign;
                sign = (s.charAt(i) == '+') ? 1 : -1;
                num = 0;//reset
            }else if (s.charAt(i) == '('){ //push the result to the stack
                numbers.push(res);
                numbers.push(sign);
                res = 0;//reset
                sign = 1;//reset
            }else if (s.charAt(i) == ')') { //remove () and pop the pre-result from the stack
                res += num * sign;
                res *= numbers.pop();
                res += numbers.pop();
                num = 0;//reset
            }
        }
        if (num != 0) res += num * sign;
        return res;
    }
X. Using tow stacks
http://buttercola.blogspot.com/2015/08/leetcode-basic-calculator.html
1. If num, push into num stack.
2. If operator: 
    -- If the op stack is empty, push the operator into the stack. 
    -- If the op has higher precedence, e.g. * or /, check the top of the op stack. 
        -- If the top operator on the op stack is a "(", push and move on. 
        -- If the top operator on the op stack has lowe precedence as well, push into the stack. 
        -- If the top operator on the op stack has the same precedence, consume one operation, and then push the op into the op stack. 
    -- If the op has lower percedence, e.g. + or -, check the top of the op stack as well. 
        -- If the top of the op stack is a left parthesis, push the op and move on
        -- Else, Pop one operator and two operands from the two stacks, resp. and push the result back. 
    -- If the op is a left parthesis, push to the op stack and move on. 

    -- If the op is a right parthesis, pop and compuate until we reach a left parthesis.   
The problem looks complicated to implement, actually could be memorized in a template way. 
If the token is a number, then push it to the num stack. 
If the token is a operator, there are 5 cases to consider:
1. If the opStack is empty
  -- push into opStack
2. If the token is + or -
  -- Check the top of the opStack. 
     -- If the top is '(', then push the token into opStack.
     -- Else (which means has higher or equal precedence), consume the stack by doing one computation. 
3. If the token is * or /
     -- If the top is '(', push the token into opStack
     -- Else if top has lower precedence ( + or -), push the token into opStack.
     -- Else if the top has equal precedence (* or /), consume the stack by doing one computation. 
4. If the token is (
    -- Push into opStack
5. If the token is )
   -- Doing computations until we see the '(' in the opStack. 
There is another corner case need to be very careful is:
If the input String has only one number, e.g. (1), 1, 1*. For OA it is still valid. So the trick to handle this edge case is in the computation method, before we pop two numbers from the numStack, we check if the size of the numStack. If less than 2, we know that this case happens. Then we only need to do is pop out the opStack until it is empty. Then the result is the only number in the numStack. 

    public int calculate(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
         
        // parse the string
        String delim = "[ ]+";
        s = s.replaceAll(delim, "");
        Stack<Integer> numStack = new Stack<Integer>();
        Stack<Character> opStack = new Stack<Character>();
         
        for (int i = 0; i < s.length(); i++) {
            char elem = s.charAt(i);
            if (Character.isDigit(elem)) {
                // To number
                int num = elem - '0';
                int j = i + 1;
                 
                while (j < s.length() && Character.isDigit(s.charAt(j))) {
                    num = num * 10 + (s.charAt(j) - '0');
                    j++;
                }
                numStack.push(num);
                i = j - 1;
            } else { // Operator
                if (opStack.isEmpty()) {
                    opStack.push(elem);
                } else if (elem == '*' || elem == '/') {
                    char top = opStack.peek();
                    if (top == '(') {
                        opStack.push(elem);
                    } else if (top == '+' || top == '-') {
                        opStack.push(elem);
                    } else {
                        compute(numStack, opStack);
                        opStack.push(elem);
                    }
                } else if (elem == '+' || elem == '-') {
                    char top = opStack.peek();
                    if (top == '(') {
                        opStack.push(elem);
                    } else {
                        compute(numStack, opStack);
                        opStack.push(elem);
                    }
                } else if (elem == '(') {
                    opStack.push(elem);
                } else if (elem == ')') { // Right ")"
                    while ((!opStack.isEmpty()) && (opStack.peek() != '(')) {
                        compute(numStack, opStack);
                    }
                    opStack.pop();
                }
            }
        }
         
        while (!opStack.isEmpty()) {
            compute(numStack, opStack);
        }
         
        return numStack.pop();
    }
     
    private void compute(Stack<Integer> numStack, Stack<Character> opStack) {
         
        if (numStack.size() < 2) {
            while (!opStack.isEmpty()) {
                opStack.pop();
            }
            return;
        }
         
        int num2 = numStack.pop();
        int num1 = numStack.pop();
         
        char op = opStack.pop();
        int ans = 0;
         
        switch(op) {
            case '+': ans = num1 + num2;
            break;
             
            case '-': ans = num1 - num2;
            break;
             
            case '*': ans = num1 * num2;
            break;
             
            case '/': ans = num1 / num2;
            break;
        }
         
        numStack.push(ans);
    }
X. Recursion
https://www.cnblogs.com/grandyang/p/4570699.html
在做了Basic Calculator III之后,再反过头来看这道题,发现递归处理括号的方法在这道题也同样适用,我们用一个变量cnt,遇到左括号自增1,遇到右括号自减1,当cnt为0的时候,说明括号正好完全匹配,这个trick在验证括号是否valid的时候经常使用到。然后我们就是根据左右括号的位置提取出中间的子字符串调用递归函数,返回值赋给num

    int calculate(string s) {
        int res = 0, num = 0, sign = 1, n = s.size();
        for (int i = 0; i < n; ++i) {
            char c = s[i];
            if (c >= '0' && c <= '9') {
                num = 10 * num + (c - '0');
            } else if (c == '(') {
                int j = i, cnt = 0;
                for (; i < n; ++i) {
                    if (s[i] == '(') ++cnt;
                    if (s[i] == ')') --cnt;
                    if (cnt == 0) break;
                }
                num = calculate(s.substr(j + 1, i - j - 1));
            }
            if (c == '+' || c == '-' || i == n - 1) {
                res += sign * num;
                num = 0;
                sign = (c == '+') ? 1 : -1;
             } 
        }
        return res;
    }
X. 思路:1. 可以先中缀表达式转为后缀表达式,然后求解之。
http://codechen.blogspot.com/2015/06/leetcode-basic-calculator.html
    void infixToPostfix(string s, vector<string> &output){
        vector<char> stack;
        for (int i = 0; i < s.size(); ++i) {
            string res;
            while (i <s.size()&& s[i] >= '0' && s[i] <= '9')
                res += s[i++];
            if (res.size() != 0)
                output.push_back(res);
         
            if (s[i] == '(')
                stack.push_back(s[i]);
         
            else if (s[i] == ')') {
                while (!stack.empty() && stack.back() != '(') {
                    string t(1,stack.back());
                    output.push_back(t);
                    stack.pop_back();
                }
                stack.pop_back();
            }
            else if (s[i]=='+' || s[i]=='-') {//"+", "-"
                while (!stack.empty()&& stack.back() != '(') {
                    string t (1,stack.back());
                    output.push_back (t);
                    stack.pop_back ();
                }
                stack.push_back(s[i]);
            }
        }
        while(!stack.empty()){
            string t(1,stack.back());
            output.push_back(t);
            stack.pop_back();
        }
    }
    int evalRPN(vector<string> &tokens) {
        vector<int> stack;
        for(int i = 0; i < tokens.size(); ++i){
            if ( tokens[i].size() > 1 || ( tokens[i][0] >= '0' && tokens[i][0] <= '9' ) ){
                stack.push_back(stoi(tokens[i]));
                continue;
            }
            int number1 = stack.back();
            stack.pop_back();
            int number2 = stack.back();
            stack.pop_back();
            switch(tokens[i][0])
            {
                case '+':
                    number2 += number1;
                    break;
                case '-':
                    number2 -= number1;
                    break;
                default:
                    break;
            }
            stack.push_back(number2);
        }
        return stack.back();
    }
     
    int calculate(string s) {
        vector<string> postfixExpression;
        infixToPostfix (s, postfixExpression);
        return evalRPN (postfixExpression);
    }

http://yuanhsh.iteye.com/blog/2194524
题目就是计算表达式  1+2*3+4 = 11可以去搜parse mathematical expression,不考虑括号 
Solution: 
use two arrays to store numbers and signs.
    nums = [1,2,3,4]
    signs = [+, *, +]
scan signs, when we meet  * or /,  and change * or / into +, corresponding nums changed to  [0, a*b] or [0, a/b]. for the example:
    nums  = [1,0,6,4]
    signs = [+,+,+].
then do (zigzag) sum.
  1. public int calcExpression(String expr) {  
  2.     //正则表达式,运算符得escape,并且用[]包裹,表示或;否则会表示"+-*/"四个都匹配才行  
  3.     String[] digits = expr.split("[\\+\\-\\*\\/]");  
  4.     //[, +, *, -, /], 第一个是leading empty string, trailing empty string会自动去掉,而头部的不会  
  5.     String[] ops = expr.split("\\d+"); // 或者下面这种做法,移除第一个数字  
  6. //  String[] ops = expr.replaceFirst("\\d+", "").split("\\d+");  
  7.       
  8.     int n = digits.length;  
  9.     int[] nums = new int[n];  
  10.     for(int i=0; i<n; i++) {  
  11.         nums[i] = Integer.valueOf(digits[i]);  
  12.     }  
  13.     for(int i=1; i<ops.length; i++) {//因为第0项是空字符串,所以从第一项开始  
  14.         if(ops[i].equals("*")) {  
  15.             nums[i] = nums[i-1] * nums[i];  
  16.             nums[i-1] = 0;  
  17.         } else if(ops[i].equals("/")) {  
  18.             nums[i] = nums[i-1] / nums[i];  
  19.             nums[i-1] = 0;  
  20.         } else if(ops[i].equals("-")) {  
  21.             //不能减,因为后面有可能是*/运算,比-的优先度高,所以要变成负数的加法,这样不影响优先级  
  22.             nums[i] = -nums[i];   
  23.         }  
  24.     }  
  25.     int sum = 0;  
  26.     for(int i=0; i<n; i++) {  
  27.         sum += nums[i];  
  28.     }  
  29.     return sum;  
  30. }  
Read full article from LeetCode – Basic Calculator (Java)

Labels

LeetCode (1432) GeeksforGeeks (1122) LeetCode - Review (1067) Review (882) Algorithm (668) to-do (609) Classic Algorithm (270) Google Interview (237) Classic Interview (222) Dynamic Programming (220) DP (186) Bit Algorithms (145) POJ (141) Math (137) Tree (132) LeetCode - Phone (129) EPI (122) Cracking Coding Interview (119) DFS (115) Difficult Algorithm (115) Lintcode (115) Different Solutions (110) Smart Algorithm (104) Binary Search (96) BFS (91) HackerRank (90) Binary Tree (86) Hard (79) Two Pointers (78) Stack (76) Company-Facebook (75) BST (72) Graph Algorithm (72) Time Complexity (69) Greedy Algorithm (68) Interval (63) Company - Google (62) Geometry Algorithm (61) Interview Corner (61) LeetCode - Extended (61) Union-Find (60) Trie (58) Advanced Data Structure (56) List (56) Priority Queue (53) Codility (52) ComProGuide (50) LeetCode Hard (50) Matrix (50) Bisection (48) Segment Tree (48) Sliding Window (48) USACO (46) Space Optimization (45) Company-Airbnb (41) Greedy (41) Mathematical Algorithm (41) Tree - Post-Order (41) ACM-ICPC (40) Algorithm Interview (40) Data Structure Design (40) Graph (40) Backtracking (39) Data Structure (39) Jobdu (39) Random (39) Codeforces (38) Knapsack (38) LeetCode - DP (38) Recursive Algorithm (38) String Algorithm (38) TopCoder (38) Sort (37) Introduction to Algorithms (36) Pre-Sort (36) Beauty of Programming (35) Must Known (34) Binary Search Tree (33) Follow Up (33) prismoskills (33) Palindrome (32) Permutation (31) Array (30) Google Code Jam (30) HDU (30) Array O(N) (29) Logic Thinking (29) Monotonic Stack (29) Puzzles (29) Code - Detail (27) Company-Zenefits (27) Microsoft 100 - July (27) Queue (27) Binary Indexed Trees (26) TreeMap (26) to-do-must (26) 1point3acres (25) GeeksQuiz (25) Merge Sort (25) Reverse Thinking (25) hihocoder (25) Company - LinkedIn (24) Hash (24) High Frequency (24) Summary (24) Divide and Conquer (23) Proof (23) Game Theory (22) Topological Sort (22) Lintcode - Review (21) Tree - Modification (21) Algorithm Game (20) CareerCup (20) Company - Twitter (20) DFS + Review (20) DP - Relation (20) Brain Teaser (19) DP - Tree (19) Left and Right Array (19) O(N) (19) Sweep Line (19) UVA (19) DP - Bit Masking (18) LeetCode - Thinking (18) KMP (17) LeetCode - TODO (17) Probabilities (17) Simulation (17) String Search (17) Codercareer (16) Company-Uber (16) Iterator (16) Number (16) O(1) Space (16) Shortest Path (16) itint5 (16) DFS+Cache (15) Dijkstra (15) Euclidean GCD (15) Heap (15) LeetCode - Hard (15) Majority (15) Number Theory (15) Rolling Hash (15) Tree Traversal (15) Brute Force (14) Bucket Sort (14) DP - Knapsack (14) DP - Probability (14) Difficult (14) Fast Power Algorithm (14) Pattern (14) Prefix Sum (14) TreeSet (14) Algorithm Videos (13) Amazon Interview (13) Basic Algorithm (13) Codechef (13) Combination (13) Computational Geometry (13) DP - Digit (13) LCA (13) LeetCode - DFS (13) Linked List (13) Long Increasing Sequence(LIS) (13) Math-Divisible (13) Reservoir Sampling (13) mitbbs (13) Algorithm - How To (12) Company - Microsoft (12) DP - Interval (12) DP - Multiple Relation (12) DP - Relation Optimization (12) LeetCode - Classic (12) Level Order Traversal (12) Prime (12) Pruning (12) Reconstruct Tree (12) Thinking (12) X Sum (12) AOJ (11) Bit Mask (11) Company-Snapchat (11) DP - Space Optimization (11) Dequeue (11) Graph DFS (11) MinMax (11) Miscs (11) Princeton (11) Quick Sort (11) Stack - Tree (11) 尺取法 (11) 挑战程序设计竞赛 (11) Coin Change (10) DFS+Backtracking (10) Facebook Hacker Cup (10) Fast Slow Pointers (10) HackerRank Easy (10) Interval Tree (10) Limited Range (10) Matrix - Traverse (10) Monotone Queue (10) SPOJ (10) Starting Point (10) States (10) Stock (10) Theory (10) Tutorialhorizon (10) Kadane - Extended (9) Mathblog (9) Max-Min Flow (9) Maze (9) Median (9) O(32N) (9) Quick Select (9) Stack Overflow (9) System Design (9) Tree - Conversion (9) Use XOR (9) Book Notes (8) Company-Amazon (8) DFS+BFS (8) DP - States (8) Expression (8) Longest Common Subsequence(LCS) (8) One Pass (8) Quadtrees (8) Traversal Once (8) Trie - Suffix (8) 穷竭搜索 (8) Algorithm Problem List (7) All Sub (7) Catalan Number (7) Cycle (7) DP - Cases (7) Facebook Interview (7) Fibonacci Numbers (7) Flood fill (7) Game Nim (7) Graph BFS (7) HackerRank Difficult (7) Hackerearth (7) Inversion (7) Kadane’s Algorithm (7) Manacher (7) Morris Traversal (7) Multiple Data Structures (7) Normalized Key (7) O(XN) (7) Radix Sort (7) Recursion (7) Sampling (7) Suffix Array (7) Tech-Queries (7) Tree - Serialization (7) Tree DP (7) Trie - Bit (7) 蓝桥杯 (7) Algorithm - Brain Teaser (6) BFS - Priority Queue (6) BFS - Unusual (6) Classic Data Structure Impl (6) DP - 2D (6) DP - Monotone Queue (6) DP - Unusual (6) DP-Space Optimization (6) Dutch Flag (6) How To (6) Interviewstreet (6) Knapsack - MultiplePack (6) Local MinMax (6) MST (6) Minimum Spanning Tree (6) Number - Reach (6) Parentheses (6) Pre-Sum (6) Probability (6) Programming Pearls (6) Rabin-Karp (6) Reverse (6) Scan from right (6) Schedule (6) Stream (6) Subset Sum (6) TSP (6) Xpost (6) n00tc0d3r (6) reddit (6) AI (5) Abbreviation (5) Anagram (5) Art Of Programming-July (5) Assumption (5) Bellman Ford (5) Big Data (5) Code - Solid (5) Code Kata (5) Codility-lessons (5) Coding (5) Company - WMware (5) Convex Hull (5) Crazyforcode (5) DFS - Multiple (5) DFS+DP (5) DP - Multi-Dimension (5) DP-Multiple Relation (5) Eulerian Cycle (5) Graph - Unusual (5) Graph Cycle (5) Hash Strategy (5) Immutability (5) Java (5) LogN (5) Manhattan Distance (5) Matrix Chain Multiplication (5) N Queens (5) Pre-Sort: Index (5) Quick Partition (5) Quora (5) Randomized Algorithms (5) Resources (5) Robot (5) SPFA(Shortest Path Faster Algorithm) (5) Shuffle (5) Sieve of Eratosthenes (5) Strongly Connected Components (5) Subarray Sum (5) Sudoku (5) Suffix Tree (5) Swap (5) Threaded (5) Tree - Creation (5) Warshall Floyd (5) Word Search (5) jiuzhang (5)

Popular Posts