Skip to content
the poor coder

Home / Topics / #algorithms

#Algorithms

191 posts · page 5 of 10
2020

Hackerrank - Almost Sorted Solution

Given an array of integers, determine whether the array can be sorted in ascending order using only one of the following operations one time. Swap two elements. Reverse one sub-segment. Determine whether one, both or…

2020

Hackerrank - The Grid Search Solution

Given a 2D array of digits or grid, try to find the occurrence of a given 2D pattern of digits. For example, consider the following grid: Assume we need to look for the following 2D pattern array: The 2D pattern begins…

2020

Hackerrank - Pairs Solution

You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value. For example, given an array of [1, 2, 3, 4] and a target value…

2020

Hackerrank - Minimum Loss Solution

Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell it in another, and she must do so at a loss. She wants to minimize her financial loss…

2020

Hackerrank - The Time in Words Solution

Given the time in numerals we may convert it into words, as shown below: At , use o' clock. For , use past, and for use to. Note the space between the apostrophe and clock in o' clock. Write a program which prints the…

2020

Hackerrank - Two Characters Solution

In this challenge, you will be given a string. You must remove characters until the string is made up of any two alternating characters. When you choose a character to remove, all instances of that character must be…

2020

Hackerrank - Flipping bits Solution

You will be given a list of 32 bit unsigned integers. Flip all the bits ( and ) and print the result as an unsigned integer. For example, your decimal input . We're working with 32 bits, so: Function Description…

2020

Hackerrank - Mark and Toys Solution

Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of different toys lying in front of him, tagged with their prices. Mark has only a certain…

2020

Hackerrank - Luck Balance Solution

Lena is preparing for an important coding competition that is preceded by a number of sequential preliminary contests. Initially, her luck balance is 0. She believes in "saving luck", and wants to check her theory. Each…

2020

Hackerrank - Grid Challenge Solution

Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they…

2020

Hackerrank - Marc's Cakewalk Solution

Marc loves cupcakes, but he also likes to stay fit. Each cupcake has a calorie count, and Marc can walk a distance to expend those calories. If Marc has eaten cupcakes so far, after eating a cupcake with calories he…

ESC