Skip to content

Instantly share code, notes, and snippets.

View rendon's full-sized avatar
🧑‍🔬
Trying new things out.

Rafael Rendón rendon

🧑‍🔬
Trying new things out.
View GitHub Profile
@rendon
rendon / persistent_array.cpp
Created September 4, 2016 18:56
Persistent array implemented in C++ using balanced binary tree.
/* Copyright 2016 Rafael Rendón Pablo <rafaelrendonpablo@gmail.com> */
// In this code array means persistent array and will be denoted by "array*".
#include <bits/stdc++.h>
using namespace std;
const int kMax = 10000;
// Node describes a node in the tree.
struct Node {
// Array* index.
int idx;
@rendon
rendon / D.cpp
Created September 8, 2016 15:13
Codeforces 368 div2#D
/* Copyright 20kSize Rafael Rendón Pablo <rafaelrendonpablo@gmail.com> */
// region Template
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
const double kEps = 10e-8;
const int kMax = 100005;
const int kInf = 1 << 30;
const int kSize = 16;
@rendon
rendon / Main.java
Last active September 30, 2017 19:45
My CF settings
/** Built using CHelper plug-in, Actual solution is at the top. */
//region
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
@rendon
rendon / tanques.cpp
Last active February 9, 2017 04:48
Tanques Omegaup DP
/* Copyright 2017 Rafael Rendón Pablo <rafaelrendonpablo@gmail.com> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
@rendon
rendon / frequent_values.cpp
Created March 23, 2017 04:47
Frequent values
/* Copyright 2017 Rafael Rendón Pablo <rafaelrendonpablo@gmail.com> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
#include <queue>
#include <map>
@rendon
rendon / homework.cpp
Created March 30, 2017 05:07
Uva Homework solution
/* Copyright 2017 Rafael Rendón Pablo <rafaelrendonpablo@gmail.com> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
#include <queue>
#include <map>
@rendon
rendon / TableReaper.java
Created May 2, 2017 21:12
Delete a list of tables, handy in testing and debugging.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
@rendon
rendon / TableCleaner.java
Created May 6, 2017 17:21
DynamoDB: Truncates table, handy in testing and debugging.
import java.util.Iterator;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.services.dynamodbv2.document.spec.ScanSpec;
import com.amazonaws.services.dynamodbv2.document.ItemCollection;
import com.amazonaws.services.dynamodbv2.document.ScanOutcome;
import com.amazonaws.services.dynamodbv2.document.Item;
@rendon
rendon / interview_question.txt
Created July 4, 2017 03:35
Interview problem
Implement a LRU (Least Recent Used) cache.
Your system queries a database for every request from your clients, you want to
serve your clients as fast as possible, in order to that you will implement a
cache on top of the database, this cache can store up to 100,000 results and
the eviction policy is LRU, that is, when the cache is full, you will remove
the least-recent used record.
You're implementation should be as efficient as possible because this will be a
critical component of our system.
@rendon
rendon / threads_excercise.txt
Created July 6, 2017 01:49
Thread excercise
You have a list of numbers, each number is in the range [1,1,000,000], you want
to find the prime factors of all of them. As usual you want to process the list
in the least amount of time, that's why you will will try to parallelize the process.
Implement an algorithm to process the list using threads, at any point you should have at most 8 threads running.