Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
Too much to do, too little time.

Gaurav Menghani reddragon

🤖
Too much to do, too little time.
View GitHub Profile
@reddragon
reddragon / Coins.cpp
Created Oct 11, 2014
Count the number of distinct ways to make an amount N, with C coins.
View Coins.cpp
#include <iostream>
#include <cstring>
// This is a toy program, so please excuse the trivial flaws.
#define MAXN 2000
#define MAXC 20
// An N*C array, hard-coding the max N = 2000, C = 20.
int r[MAXN][MAXC];
int cval[MAXC];
int N, C;
View gist:319b2a89d6bbb5ca0836
pttrns.com => For patterns.
Reference Counting (arc).
@ for NSLiteral, so that "" doesn't mean C-string.
Set tableView delegate and dataSource = self.
Set numberOfRowsInSection
Set cell
View gist:95a689aaadea3365a144
If you delete the default Storyboard etc., put this in the AppDelegate.m
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
When setting things like images in cells, reuse the cells. For some reason, if you allocate a fresh cell, it doesn't work.
Pass data between controllers, rather than views, or modifying the view of the next controller.
View gist:b43132bfe5801ca90466
* Select Image View Mode for Image Resizing if its bigger than the screen.
* Delegate - Add callbacks somewhere else when something changes.
* protocol and interface are synonyms in objc.
Delegate Pattern
* Can use delegate instead of passing around controllers.
* Mark protocol methods as @optional if you dont need them.
* Check this via respondsToSelector method.
* KVO
View gist:195dd2ce87f62d2db66d
1. Do binary search on a rotated array.
Eg., given [100, 110, 121, 5, 11, 44, 78, 91, 99], be able to binary search on it.
2. Implement the * and / operations without actual multiplication and division.
3. Implement the ^ operator without using any in-build exponentiation methods.
4. Implement the median of an unsorted array in O(n).
5. Implement sqrt()
@reddragon
reddragon / gist:bca9be25e50a475044a7
Last active Aug 29, 2015
Interesting Companies
View gist:bca9be25e50a475044a7
Delivery/Logistics:
Instacart
Munchery
Lyft
Sidecar
Uber
Thumbtack
DoorDash
Grubhub
Seamless
View djikstra-slow.cpp
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
struct Edge {
int src, dst;
int w;
};
View githubcommitinfo.rb
#!/usr/bin/env ruby
# githubcommitinfo.rb - Fetches info about a commit on github.
# http://develop.github.com/p/commits.html
# Usage: $ ./githubcommitinfo.rb <gh_username> <gh_repo> <gh_branch>
# Dependencies:
# rubygems
View cse506_proposal
Extending the JOS File System
People:
Aniruddha Laud
Gaurav Menghani
Synopsis:
The JOS filesystem is a bare-bones filesystem, which can be improved upon by adding
features of a contemporary filesystems. We propose implementing the following
View ae2a-draft.cpp
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define MAXN 1000
bool done[MAXN+10][MAXN*6+10];
long double dp[MAXN+10][MAXN*6+10];