Copy the .vimrc
file below
This file contains 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
/* | |
* In a competition to see who would use the least pointers | |
* for reversing nodes in a linked list, I think this solution | |
* should be entered. There are easier solutions to read/spot, | |
* but I think this is the most elegant. | |
*/ | |
class Solution { | |
public: | |
ListNode *swapPairs(ListNode *head) { |
This file contains 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
/* | |
* The difficult part about this problem was figuring out it was | |
* only BFS. The restrictions of time O(nlogn) and space O(n) | |
* were easy to figure out. | |
*/ | |
#include <algorithm> | |
#include <queue> | |
#include <utility> | |
#include <iostream> |
This file contains 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
/* The classic knapsack problem, solved with | |
* dynamic programming. In the dp array, | |
* rows represent item subset choice, columns | |
* represent weights, and individual cells represent | |
* values. The knapsack algorithm can also be adapted | |
* to searching subsets for a target value. Just set | |
* weights equal to values, and one can then search subsets | |
* for a value. | |
* | |
* If there are n values, and the target value is t, then |
This file contains 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
/* | |
* My Canonical example of a C bubble sort | |
* This is still O(n^2) (no getting away from that) | |
* but it is slightly more efficient than the classic | |
* examples given in textbooks because the inner loop | |
* loops one less every time | |
*/ | |
void bubbleSort_c(int *arr, int size) { | |
int temp = 0; |
This file contains 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
/* | |
* Dynamic programming at its best! The trick is | |
* that erasing a character, and inserting a character | |
* are inverse operations and therefore can be considered | |
* just one operation (See comments below) | |
*/ | |
class Solution { | |
public: |
This file contains 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
/* | |
* This is a very cool method to perform the leetcode task. | |
* It is time O(n) (n being the size of string S) if it is | |
* implemented with an unordered_map on line 65, otherwise it | |
* is O(n*log(m)) (m being the size of the vector L) | |
* | |
* This method demonstrates how hashes can be used for | |
* comparison instead of strings. It is inspired by | |
* the topcoder article: http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=stringSearching | |
*/ |
This file contains 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
{ | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true | |
}, | |
"plugins": ["react"], | |
"ecmaFeatures": { |