Skip to content
the poor coder

Home / Topics / #algorithms

#Algorithms

191 posts · page 4 of 10
2020

Hackerrank - Stock Maximize Solution

Your algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next number of days. Each day, you can either buy one share of…

2020

Hackerrank - Halloween party Solution

Alex is attending a Halloween party with his girlfriend, Silvia. At the party, Silvia spots the corner of an infinite chocolate bar (two dimensional, infinitely long in width and length). If the chocolate can be served…

2020

Hackerrank - Counting Sort 1 Solution

Comparison Sorting Quicksort usually has a running time of , but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison sorts, i.e. they sort a list…

2020

Hackerrank - Frequency Queries Solution

You are given queries. Each query is of the form two integers described below: - : Insert x in your data structure. - : Delete one occurence of y from your data structure, if present. - : Check if any integer is present…

2020

Hackerrank - Minimum Swaps 2 Solution

You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the…

2020

Hackerrank - Count Triplets Solution

You are given an array and you need to find number of triplets of indices such that the elements at those indices are in geometric progression for a given common ratio and . For example, . If , we have and at indices…

2020

Hackerrank - Greedy Florist Solution

A group of friends want to buy a bouquet of flowers. The florist wants to maximize his number of new customers and the money he makes. To do this, he decides he'll multiply the price of each flower by the number of that…

2020

Hackerrank - Max Min Solution

You will be given a list of integers, , and a single integer . You must create an array of length from elements of such that its unfairness is minimized. Call that array . Unfairness of an array is calculated as Where…

ESC