title-img


Red Knight's Shortest Path

In ordinary chess, the pieces are only of two colors, black and white. In our version of chess, we are including new pieces with unique movements. One of the most powerful pieces in this version is the red knight. The red knight can move to six different positions based on its current position (UpperLeft, UpperRight, Right, LowerRight, LowerLeft, Left) as shown in the figure below. The board is a grid of size . Each cell is identified with a pair of coordinates , where is the row number

View Solution →

Bike Racers

There are bikers present in a city (shaped as a grid) having bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first bikes are acquired in the minimum time. Every

View Solution →

Task Scheduling

You have a long list of tasks that you need to do today. To accomplish task you need minutes, and the deadline for this task is . You need not complete a task at a stretch. You can complete a part of it, switch to another task, and then switch back. You've realized that it might not be possible to complete all the tasks by their deadline. So you decide to do them in such a manner that the maximum amount by which a task's completion time overshoots its deadline is minimized. Input Format

View Solution →

Similar Pair

A pair of nodes, , is a similar pair if the following conditions are true: node is the ancestor of node Given a tree where each node is labeled from to , find the number of similar pairs in the tree. Function Description Complete the similarPair function in the editor below. It should return an integer that represents the number of pairs meeting the criteria. similarPair has the following parameter(s): n: an integer that represents the number of nodes k: an integer edges:

View Solution →

Absolute Element Sums

Given an array of integers, you must answer a number of queries. Each query consists of a single integer, , and is performed as follows: Add to each element of the array, permanently modifying it for any future queries. Find the absolute value of each element in the array and print the sum of the absolute values on a new line. Tip: The Input/Output for this challenge is very large, so you'll have to be creative in your approach to pass all test cases. Function Description Complete th

View Solution →