These toy examples are for helping with understanding C/C++. There is an excellent C++ samples site which demonstrates many useful things.
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": { |
This gist details the following:
- Converting a Subversion (SVN) repository into a Git repository
- Purging the resultant Git repository of large files
- Retrieve a list of SVN commit usernames
Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).
The MIT License (MIT)
Copyright (c) 2013 Barry Steyn
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
/* | |
* 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
class Solution { | |
public: | |
void rotate(vector<vector<int> > &matrix) { | |
int N = matrix.size()-1, | |
temp = 0; | |
for (int i=0; i < N; i++) { | |
for (int j=0; j+i < N; j++) { | |
//Only one temp variable is needed |
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; |
NewerOlder