How to create and initialize 2D arrays of integers with:
- M rows
- N columns
- X initial value
int dp[M][N] = { [0 ... M-1] = { [0 ... N-1] = X } };
/* | |
Heap Property: | |
* MinHeap: For every object x, the key of x is <= the keys of its children | |
* MaxHeap: For every object x, the key of x is >= the keys of its children | |
---------------------------------------------------------------------------------------------------- | |
Insert: |
/* | |
* Javascript version of C++ equal_range via lower_bound and upper_bound | |
* | |
* Gist: https://gist.github.com/claytonjwong/53bd1c1489b12eccad176addb8afd8e0 | |
*/ | |
let lowerBound = (A, T) => { | |
let N = A.length, | |
i = 0, | |
j = N; |
use std::str; | |
fn main() { | |
// -- FROM: vec of chars -- | |
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
// to String | |
let string1: String = src1.iter().collect::<String>(); | |
// to str | |
let str1: &str = &src1.iter().collect::<String>(); | |
// to vec of byte |
How to create and initialize 2D arrays of integers with:
int dp[M][N] = { [0 ... M-1] = { [0 ... N-1] = X } };
template< typename T > | |
class Solution | |
{ | |
using Vector = vector< T >; | |
using Iter = typename Vector::iterator; | |
Vector go( Vector&& A ) | |
{ | |
auto N{ A.size() }; | |
if( N < 2 ) return A; |
// | |
// BUBBLE-SORT | |
// | |
// loop-invariant: | |
// | |
// the right-most i elements are the largest i elements in A[0:N), 0<=i<N | |
// sorted in ascending order | |
// | |
void bubble_sort1(vector<int>& A){ | |
bool swapped; |
For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.
After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
To test a glob
pattern go over to globtester and play around with creating your own file structure online, it's super easy to get started that way.
If you want to test out a glob
pattern in the terminal use echo
followed by the pattern, for instance.
echo **/*.js
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |