This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/median-of-stream-of-integers-running-integers/ | |
| // Time complexity : O(nlogn) | |
| // Space complexity : O(n) | |
| #include <assert.h> | |
| #include <queue> | |
| class Median { | |
| public: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion/ | |
| #include <assert.h> | |
| #include <stdio.h> | |
| #include <stack> | |
| class Node { | |
| public: | |
| Node(int v) | |
| : value(v), | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/print-postorder-from-given-inorder-and-preorder-traversals/ | |
| #include <assert.h> | |
| #include <stdio.h> | |
| int find(int *array, int n, int value) { | |
| for (int i = 0; i < n; i++) { | |
| if (array[i] == value) return i; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://codercareer.blogspot.kr/2013/02/no-44-maximal-stolen-values.html | |
| #include <algorithm> | |
| #include <assert.h> | |
| #include <cstring> | |
| #define MAX_CACHE 100 | |
| int maxStolenValueUtil(const int *values, int length, int idx, int *cache) { | |
| if (idx >= length) return 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/longest-palindromic-substring-set-2/ | |
| #include <algorithm> | |
| #include <assert.h> | |
| #include <string.h> | |
| int length_pal(const char *str) { | |
| int len = strlen(str); | |
| int maxlen = 1; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/longest-palindrome-substring-set-1/ | |
| #include <assert.h> | |
| #include <string.h> | |
| #define MAX_LEN 100 | |
| bool cache[MAX_LEN][MAX_LEN]; | |
| int length_pal(const char *str) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-complete-tree-or-not/ | |
| #include <assert.h> | |
| #include <queue> | |
| class Node { | |
| public: | |
| Node(int v) | |
| : value(v), | |
| left(0), | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/topological-sorting/ | |
| #include <stdio.h> | |
| #include <vector> | |
| class Graph { | |
| public: | |
| Graph(int nodes) : | |
| nodeCount(nodes) { | |
| edges = new std::vector<int>[nodes]; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://www.geeksforgeeks.org/majority-element/ | |
| // It is assumed that all numbers in array are positive. | |
| #include <assert.h> | |
| int count(int *array, int start, int end, int num) { | |
| int c = 0; | |
| for (int i = start; i <= end; i++) { | |
| if (array[i] == num) c++; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // A solution for http://codercareer.blogspot.kr/2011/09/no-03-maximum-sum-of-all-sub-arrays.html | |
| // It is assumed that there is at least one positive number in the array. | |
| #include <algorithm> | |
| #include <assert.h> | |
| #include <string.h> | |
| #define LEN 10 | |
| int cache[LEN]; |