Skip to content

Instantly share code, notes, and snippets.

View amulyakashyap09's full-sized avatar
🎯
Focusing

Amulya Kashyap amulyakashyap09

🎯
Focusing
  • Greater Noida
View GitHub Profile
@amulyakashyap09
amulyakashyap09 / union.py
Created December 31, 2017 16:30
Union Problem | Hackerrank
n = int(input())
enp = set(map(int, input().split()))
b = int(input())
fnp = set(map(int, input().split()))
c = enp.union(fnp)
print(len(c))
@amulyakashyap09
amulyakashyap09 / intersection.py
Created December 31, 2017 16:32
Intersection Problem | Hackerrank
n = int(input())
enp = set(map(int, input().split()))
b = int(input())
fnp = set(map(int, input().split()))
c = enp.intersection(fnp)
print(len(c))
@amulyakashyap09
amulyakashyap09 / difference.py
Created December 31, 2017 16:33
Difference of a set | Hackerrank
n = int(input())
enp = set(map(int, input().split()))
b = int(input())
fnp = set(map(int, input().split()))
c = enp.difference(fnp)
print(len(c))
@amulyakashyap09
amulyakashyap09 / symmetric_difference.py
Created December 31, 2017 16:36
Symmetric Difference of Sets | Hackerrank
n = int(input())
enp = set(map(int, input().split()))
b = int(input())
fnp = set(map(int, input().split()))
c = enp.symmetric_difference(fnp)
print(len(c))
@amulyakashyap09
amulyakashyap09 / mutations.py
Created January 1, 2018 12:32
mutations.py
length=int(input())
s=set(map(int, input().split()))
N=int(input())
for i in range(N):
(p, q)=input().split()
s2=set(map(int, input().split()))
if p=='intersection_update':
s.intersection_update(s2)
elif p=='update':
@amulyakashyap09
amulyakashyap09 / min_frequency.py
Created January 1, 2018 14:04
The captain's room | Hackerrank
from itertools import groupby
K = int(input())
lis = list(map(int, input().split()))
dic = {}
min=0
for i in lis:
if str(i) not in dic:
dic[str(i)] = 1;
@amulyakashyap09
amulyakashyap09 / subset.py
Created January 2, 2018 04:44
Subset | Hackerrank
for i in range(int(input())): #More than 4 lines will result in 0 score. Blank lines won't be counted.
a = int(input()); A = set(input().split())
b = int(input()); B = set(input().split())
print(A.issubset(B))
@amulyakashyap09
amulyakashyap09 / rest_naming_conventions.html
Created February 22, 2018 14:21
Rest Naming Conventions
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="exporter-version" content="Evernote Mac 6.13.3 (455969)" />
<meta name="altitude" content="331.4588012695312" />
<meta name="author" content="amulyakashyap09@gmail.com" />
<meta name="created" content="2018-02-22 13:17:51 +0000" />
<meta name="latitude" content="30.71890173873824" />
<meta name="longitude" content="76.8103098519497" />
@amulyakashyap09
amulyakashyap09 / find_minimum_swaps_to_sort_array.js
Created April 17, 2018 09:11
find minimum number of swaps to reorder the array in ascending
function minSwaps(arr) {
//using selection sort O(N^2)
let n = arr.length;
let initial_min_no = 0,
initial_min_index = 0,
swaps = 0;
for (let i = 0; i < n - 1; i++) {
@amulyakashyap09
amulyakashyap09 / is_binary_search_tree.py
Created April 28, 2018 19:51
validates whether tree is binary search tree or not
""" Node is defined as
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
"""
def isBSTUtil(node, min, max):
if node.data <= min: