Skip to content

Instantly share code, notes, and snippets.

View tanmaybaranwal's full-sized avatar
🏢
Working on office account. 😉

Tanmay Baranwal tanmaybaranwal

🏢
Working on office account. 😉
View GitHub Profile
@tanmaybaranwal
tanmaybaranwal / find_triplets.py
Created April 21, 2021 09:24
In how many ways can you find all the triplets in a given array of n distinct elements with a sum equal to 0?
def find_triplets(array):
n = len(array)
array.sort()
triplets = []
for index in range(0, n-1):
starting_pointer = index + 1
end_pointer = n - 1
curr_value = array[index]
while (starting_pointer < end_pointer):
if (curr_value + array[starting_pointer] + array[end_pointer] == 0):
@tanmaybaranwal
tanmaybaranwal / string_classifier.py
Created August 6, 2019 09:20
Get unique smallest string from the list
class StringClassifier:
def __init__(self, input_data: list):
self.input_list = input_data
self.input_dict = dict(enumerate(input_data))
self.sorted_dict = dict(enumerate(list(map(lambda x: "".join(sorted(x)), input_data))))
def process(self) -> list:
reverse_dict = {}
processed_list = []
for key, value in self.sorted_dict.items():
@tanmaybaranwal
tanmaybaranwal / istio-cluster.jinja
Created August 17, 2018 05:27
Istio Quickstart Deployment with Debian 9
{% set CLUSTER_NAME = env['deployment'] + '-' + env['name'] %}
resources:
- name: {{ properties['gkeClusterName'] }}
type: container.v1.cluster
properties:
zone: {{ properties['zone'] }}
cluster:
name: {{ properties['gkeClusterName'] }}
@tanmaybaranwal
tanmaybaranwal / ExoPlayerActivity.java
Last active February 22, 2017 11:40
ExoPlayer DASH Media is not playing in Samsung Galaxy Duos 4.1.2
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
/**
* Created by tanmaybaranwal on 14/02/17.
*/
import android.app.Activity;
import android.net.Uri;