Skip to content

Instantly share code, notes, and snippets.

View pratt3000's full-sized avatar
〽️
meh

Prathamesh pratt3000

〽️
meh
View GitHub Profile
@pratt3000
pratt3000 / Unoai_main_1.cpp
Last active August 28, 2023 23:51
UNO.ai: Islands - m x n 2D binary grid
#include<bits/stdc++.h>
using namespace std;
// Initialize helper data structures and visited array.
vector<int> x{-1, 1, 0, 0};
vector<int> y{0, 0, -1, 1};
int visited[1000][1000] = {0};
// If its a visited node, then ignore.
// If the element is 0 then ignore as there is no island on that path, i.e. the coast.
@pratt3000
pratt3000 / unoai_main_2.py
Last active August 28, 2023 23:48
UNO.ai: Triplets
def get_triplets(arr, to_sum):
# Array length.
n = len(arr)
# Iterate through the array twice [O(n^2)] and check if the remainder of the sum is present in the dict.
# This helps bring the algorithm from O(n^3) to O(n^2).
ans = []
for i in range(n - 2):
pseudo_sums = dict()