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
// 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. |
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
// 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 |
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
// 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.*; |
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
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>", |