Skip to content

Instantly share code, notes, and snippets.

@sunloverz
sunloverz / sum_of_pairs.java
Last active February 10, 2021 05:54
Sum of pairs
package hash_table;
import java.util.ArrayList;
public class SumOfPairs {
public static void getPairs(int[] arr, int sum) {
int length = arr.length;
boolean[] seen = new boolean[length];
ArrayList<ArrayList<Integer>> list = new ArrayList<>();
ArrayList<Integer> temp;
def get_pairs(arr, sum)
len = arr.length
seen = Array.new(len, false)
result = []
for i in 0..len-1
for j in i+1..len-1
if arr[i] + arr[j] == sum && !seen[j] && !seen[i]
seen[i], seen[j] = true, true
result << [arr[i], arr[j]]
@sunloverz
sunloverz / gist:70575d09e67638c9b55ea53005ceafeb
Created June 2, 2021 11:08 — forked from guisehn/gist:6648c8fdcd1102a22a22
Backup Heroku Postgres database and restore to local database

Grab new backup

Command: heroku pg:backups capture -a [app_name]

Download

Command: curl -o latest.dump `heroku pg:backups public-url -a [app_name]`

Restore backup dump into local db