title-img


Reverse Shuffle Merge

Given a string, A, we define some operations on the string as follows: a. denotes the string obtained by reversing string . Example: b. denotes any string that's a permutation of string . Example: c. denotes any string that's obtained by interspersing the two strings & , maintaining the order of characters in both. For example, & , one possible result of could be , another could be , another could be and so on. Given a string such that for some string , find the lexico

View Solution →

Hash Tables: Ice Cream Parlor

Each time Sunny and Johnny take a trip to the Ice Cream Parlor, they pool their money to buy ice cream. On any given day, the parlor offers a line of flavors. Each flavor has a cost associated with it. Given the value of money and the cost of each flavor for trips to the Ice Cream Parlor, help Sunny and Johnny choose two distinct flavors such that they spend their entire pool of money during each visit. ID numbers are the 1- based index number associated with a cost. For each trip to the pa

View Solution →

Swap Nodes [Algo]

A binary tree is a tree which is characterized by one of the following properties: It can be empty (null). It contains a root node only. It contains a root node with a left subtree, a right subtree, or both. These subtrees are also binary trees. In-order traversal is performed as Traverse the left subtree. Visit root. Traverse the right subtree. For this in-order traversal, start from the left child of the root node and keep exploring the left subtree until you reach a leaf. When you

View Solution →

Pairs

Given an array of integers and a target value, determine the number of pairs of array elements that have a difference equal to the target value. Function Description Complete the pairs function below. pairs has the following parameter(s): int k: an integer, the target difference int arr[n]: an array of integers Returns int: the number of pairs that satisfy the criterion Input Format The first line contains two space-separated integers n and k, the size of arr and the targe

View Solution →

Number Line Jumps

You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. You have to figure out a way to get both kangaroos at the same location at the same time as part of the show. If it is possible, return

View Solution →