Skip to content

Instantly share code, notes, and snippets.

View abhisheksharma14's full-sized avatar

Abhishek Sharma abhisheksharma14

View GitHub Profile
// To calculate maximum profits from stock exchange with given stock rate per day.
/*
You're given an array of positive integers representing the prices of a single stock on
various days (each index in the array represents a different day). You're also
given an integer k, which represents the number of transactions
you're allowed to make. One transaction consists of buying the stock on a
given day and selling it on another, later day.
Write a function that returns the maximum profit that you can make by buying
and selling the stock, given k transactions.
// Find distinct years
/*
Find all the distinct years present in the a given string.
*/
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main
@abhisheksharma14
abhisheksharma14 / costReducer.java
Last active August 4, 2022 17:02
Competitive Programming Practice.
// Adding numbers with reduced cost.
/*
Victor has an array of size n. He loves to play with these n numbers.
Each time he plays with them, he picks up two consicutive numbers and
adds them. On adding both the numbers, it costs him k*(sum of numbers).
Find the minimum cost of adding all the numbers.
*/
import java.util.*;
@abhisheksharma14
abhisheksharma14 / s3_delete_restore.txt
Created November 8, 2019 13:43
Script to delete/restore objects from S3
var AwsS3 = require ('aws-sdk/clients/s3');
let cred = {
test: {
"accessKeyId": "<test-key>",
"secretAccessKey": "<test-secret>",
"region": '<region>',
},
live: {
"accessKeyId": "<live-key>",
"secretAccessKey": "<live-secret>",