Skip to content

Instantly share code, notes, and snippets.

View siddydutta's full-sized avatar

Siddhartha Dutta siddydutta

View GitHub Profile
@siddydutta
siddydutta / Main.java
Created April 15, 2023 07:07
TechGig Code Gladiators 2023 Open Coding Round
/*
The Magic Wand
You are a wizard who possesses a magical wand that can be used to change the values of an array. Your wand has two powers: Increase and Decrease. With each use of the wand, you can either increase or decrease any element of the array by 1.
One day, a group of villagers came to you with a problem. They had an array of positive integers of size N and a set of queries of size M. For each query, queries[i], they wanted to make all the elements of the array equal to queries[i] using your magic wand.
To help the villagers, you decided to use your magic wand to perform the operations. However, each time you perform an operation, the cost of using your wand increases. The cost of using your wand for an operation on an element is equal to the absolute difference between the value of the element and the desired value after the operation.
Example:
If you want to change an element from 5 to 3, it will cost you 2. If you want to change an element from 7 to 8, it will cost you 1.
You can perform any num
# -*- coding: utf-8 -*-
import os
import requests
'''
Environment variables should contain the following mappings:
AMADEUS_API_KEY = YOUR_API_KEY
AMADEUS_API_SECRET = YOUR_API_SECRET
'''
@siddydutta
siddydutta / DSA_BinarySearchTemplate.py
Last active November 20, 2021 05:27
A Python template to solve problems involving binary search.
"""
A Python template to solve problems involving binary search.
Template based on this post: https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/discuss/769704/Python-Clear-explanation-Powerful-Ultimate-Binary-Search-Template.-Solved-many-problems.
"""
def binary_search(array) -> int:
def condition(value) -> bool:
# Conditional logic based on question
# Returns true if current value satisfies requirements
# binary search will take care of finding the minimal val
return
@siddydutta
siddydutta / AZ-900-Notes.txt
Created September 11, 2021 12:53
AZ-900 exam notes in byte sizes
Azure Fundamentals Part 1: Describe core Azure concepts
Cloud computing is the delivery of computing services over the internet by using a pay-as-you-go pricing model. You typically pay only for the cloud services you use, which helps you:
Lower your operating costs.
Run your infrastructure more efficiently.
Scale as your business needs change.
Types of Cloud Models
Public cloud
No capital expenditures to scale up.
@siddydutta
siddydutta / system_test_script.py
Created August 30, 2021 12:54
Coursera - Continuous Delivery & DevOps - System Test Example
# -*- coding: utf-8 -*-
'''
This is a program for University of Virginia's "Continous Delivery and DevOps"
course on Coursera. This script demonstrates the System Test example using
the Selenium webdriver.
'''
from random import randint
from selenium import webdriver
@siddydutta
siddydutta / script.js
Created August 29, 2021 07:14
HackerRank - JavaScript Basic Assessment - Country Codes
// HackerRank's NodeJS environment allows the `request` package.
const request = require('request');
function fetch(url) {
return new Promise((resolve, reject) => {
request(url, function (error, response, body) {
if (error)
reject(error)
else
resolve(body)
@siddydutta
siddydutta / DSA_SubstringTemplate.py
Last active August 16, 2021 16:01
A Python template to solve most problems involving substrings using a two-pointer approach.
"""
A Python template to solve most problems involving substrings using a two-pointer approach.
Template based on this post: https://leetcode.com/problems/minimum-window-substring/discuss/26808/Here-is-a-10-line-template-that-can-solve-most-'substring'-problems
"""
def substring(string: str) -> int:
counter = int() # To check if the substring is valid
left, right = 0, 0 # Two pointers, right pointer is exclusive
length = int() # Length of the substring
map = dict() # Intialize the hash map here, collections.Counter is useful
@siddydutta
siddydutta / CodingMinutesDP.py
Last active August 9, 2021 09:26
Questions based on the session on Dynamic Programming by Apaar Kamal
# -*- coding: utf-8 -*-
"""
Questions based on the session on Dynamic Programming by Apaar Kamal.
https://join.codingminutes.com/dp-08
Alice and Bob are playing a game. Alice plays first.
We have a pile of n stones.
Q1.
@siddydutta
siddydutta / convulation.py
Created November 26, 2020 15:19
A function that applies the convolution operation to a given image with a given kernel with or without padding.
# -*- coding: utf-8 -*-
import cv2
import numpy as np
def convulate(image, kernel, padding=False, paddingType=cv2.BORDER_CONSTANT):
'''
@param image: 2D array of type <numpy.ndarray> for given image.
@param kernel: 2D array of type <numpy.ndarray> for given kernel.
@param padding: Type <bool> to indicate if padding required.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
raw_data = pd.read_csv('data.csv',encoding='latin1',thousands=',')
# Top 5 Countries Affected
data = raw_data[['Country,Other','TotalCases','TotalDeaths','TotalRecovered']]
most_affected = data.sort_values('TotalCases', ascending=False)[:5]
plt.figure(figsize=(10,5))