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
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| int main() { | |
| int input = 2; | |
| int tmp; | |
| for (tmp=1 ; tmp <= input ; tmp *= 2); |
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
| #include <iostream> | |
| #include <string> | |
| #include <unordered_map> | |
| #include <list> | |
| using namespace std; | |
| template <class K, class V> class LRU { | |
| private: | |
| /* Members */ |
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
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| #include <list> | |
| using namespace std; | |
| template <class T> class Node { | |
| 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
| #include <iostream> | |
| #include <map> | |
| using namespace std; | |
| int fib(int n) { | |
| static map<int,int> mem{{1,1}, {0,1}}; | |
| if (mem.count(n) > 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
| // ref: https://en.wikipedia.org/wiki/3SUM | |
| #include <iostream> | |
| #include <map> | |
| #include <algorithm> | |
| using namespace std; | |
| // Brute force solution O(n^3) | |
| bool sum3A(int arr[], int n) { |
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
| #include <iostream> | |
| #include <map> | |
| using namespace std; | |
| static map<int, string> text { | |
| {0, ""}, | |
| {1, "one"}, | |
| {2, "two"}, | |
| {3, "three"}, |
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
| #include <iostream> | |
| using namespace std; | |
| int magicSearch(int arr[], int start, int end) { | |
| if (start > end) | |
| return -1; | |
| int index = (start + end) / 2; | |
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
| #include <iostream> | |
| #include <list> | |
| #include <unistd.h> | |
| using namespace std; | |
| enum Move { | |
| UP, | |
| RIGHT, | |
| DOWN, |
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
| #include <iostream> | |
| using namespace std; | |
| class Parts { | |
| string specification; | |
| public: | |
| // Constructor | |
| Parts(string specification) { |
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
| #include <iostream> | |
| using namespace std; | |
| class Singlton { | |
| public: | |
| static Singlton* getInstance() { | |
| static Singlton* instance = nullptr; | |