Skip to content

Instantly share code, notes, and snippets.

@itayB
itayB / less-cheatsheet.md
Created January 28, 2017 08:40 — forked from glnds/less-cheatsheet.md
Less Cheatsheet

Less Cheatsheet

less {filename}
Navigation
SPACE forward one window
b backward one window
d forward half window
@itayB
itayB / singlton.cpp
Created September 27, 2016 19:39
Singlton Example (Design Pattern)
#include <iostream>
using namespace std;
class Singlton {
public:
static Singlton* getInstance() {
static Singlton* instance = nullptr;
@itayB
itayB / abstractFactory.cpp
Created September 27, 2016 19:04
Abstract Factory Example (Design Pattern)
#include <iostream>
using namespace std;
class Parts {
string specification;
public:
// Constructor
Parts(string specification) {
@itayB
itayB / snake.cpp
Last active September 27, 2016 18:18
Snake game - Object Oriented Design
#include <iostream>
#include <list>
#include <unistd.h>
using namespace std;
enum Move {
UP,
RIGHT,
DOWN,
#include <iostream>
using namespace std;
int magicSearch(int arr[], int start, int end) {
if (start > end)
return -1;
int index = (start + end) / 2;
@itayB
itayB / CrackingTheCodeInterview-16.8.cpp
Created September 26, 2016 15:03
English Int - Given any integer, print an English phrase that describes the integer
#include <iostream>
#include <map>
using namespace std;
static map<int, string> text {
{0, ""},
{1, "one"},
{2, "two"},
{3, "three"},
@itayB
itayB / 3sum.cpp
Created September 25, 2016 18:48
Given array with integers, return 3 number with sum of zero.
// 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) {
#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) {
@itayB
itayB / CrackingTheCodeInterview4.8.cpp
Last active September 23, 2016 07:04
First Common Ancestor
#include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;
template <class T> class Node {
public:
@itayB
itayB / lru.cpp
Created September 21, 2016 21:00
Implement LRU cache
#include <iostream>
#include <string>
#include <unordered_map>
#include <list>
using namespace std;
template <class K, class V> class LRU {
private:
/* Members */