This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
NewerOlder