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
// Time complexity O(nlgn). Space complexity O(n) | |
#include "stdafx.h" | |
#include "iostream" | |
#include "list" | |
using namespace std; | |
template<typename T> | |
class TreeNode | |
{ | |
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
// Time complexity best:O(|t1| + |t2|), worst:O(|t1|*|t2|). Space complexity O(1) | |
#include "stdafx.h" | |
#include "iostream" | |
using namespace std; | |
template<typename T> | |
class TreeNode | |
{ | |
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
// Time complexity O((logn)^2). Space complexity O(1) | |
#include "iostream" | |
#include "assert.h" | |
using namespace std; | |
template<typename T> | |
class TreeNode | |
{ | |
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
// Time complexity O(n). Space complexity O(n) | |
#include "stdafx.h" | |
#include "iostream" | |
using namespace std; | |
const int MAXINT = 0x7fffffff; | |
template<typename T> | |
class TreeNode | |
{ |
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
// Time complexity O(n). Space complexity O(n) | |
#include "stdafx.h" | |
#include "iostream" | |
#include "vector" | |
using namespace std; | |
const int MAXINT = 0x7fffffff; |
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
// Time complexity O(n). Space complexity O(n) | |
#include "stdafx.h" | |
#include "iostream" | |
using namespace std; | |
template<typename T> | |
class TreeNode | |
{ | |
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
// Time complexity O(n). Space complexity O(n) | |
#include "iostream" | |
using namespace std; | |
#define N 7 | |
// Adjacent array( which has a loop 0-1-4-2-0) | |
int AdjArr[N][N] = {0, 1, 1, 1, 0, 0, 0, | |
0, 0, 0, 0, 1, 0, 0, | |
1, 0, 0, 0, 1, 0, 0, | |
0, 0, 0, 0, 0, 1, 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
// Time complexity O(n). Space complexity O(n) | |
#include "iostream" | |
#include "assert.h" | |
using namespace std; | |
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
#define ABS(a) (a > 0 ? a : -a) | |
template<typename T> | |
class TreeNode |
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
// Time complexity O(n^2). Space complexity O(n) | |
#include "iostream" | |
using namespace std; | |
#define NUL 0x7fffffff; | |
//const int NUL = 0x7fffffff; | |
const int MAXSTKNUM = 1000; | |
template<typename T> | |
class Stack |
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
// Time complexity O(1). Space complexity O(n) | |
#include "iostream" | |
using namespace std; | |
#define NUL 0x7fffffff; | |
//const int NUL = 0x7fffffff; | |
const int MAXSTKNUM = 1000; | |
template<typename T> | |
class Stack |
NewerOlder