title-img


Maximum Perimeter Triangle

Given an array of stick lengths, use of them to construct a non-degenerate triangle with the maximum possible perimeter. Return an array of the lengths of its sides as integers in non-decreasing order. If there are several valid triangles having the maximum perimeter: Choose the one with the longest maximum side. If more than one has that maximum, choose from them the one with the longest minimum side. If more than one has that maximum as well, print any one them. If no non-degenerate

View Solution →

Beautiful Pairs

You are given two arrays, and , both containing integers. A pair of indices is beautiful if the element of array is equal to the element of array . In other words, pair is beautiful if and only if . A set containing beautiful pairs is called a beautiful set. A beautiful set is called pairwise disjoint if for every pair belonging to the set there is no repetition of either or values. For instance, if and the beautiful set is not pairwise disjoint as there is a repetition of , t

View Solution →

Candies

Alice is a kindergarten teacher. She wants to give some candies to the children in her class. All the children sit in a line and each of them has a rating score according to his or her performance in the class. Alice wants to give at least 1 candy to each child. If two children sit next to each other, then the one with the higher rating must get more candies. Alice wants to minimize the total number of candies she must buy. Example arr = [ 4, 6, 4, 5 , 6 , 2 ] She gives the students

View Solution →

Sherlock and The Beast

Sherlock Holmes suspects his archenemy Professor Moriarty is once again plotting something diabolical. Sherlock's companion, Dr. Watson, suggests Moriarty may be responsible for MI6's recent issues with their supercomputer, The Beast. Shortly after resolving to investigate, Sherlock receives a note from Moriarty boasting about infecting The Beast with a virus. He also gives him a clue: an integer. Sherlock determines the key to removing the virus is to find the largest Decent Number having th

View Solution →

Priyanka and Toys

Priyanka works for an international toy company that ships by container. Her task is to the determine the lowest cost way to combine her orders for shipping. She has a list of item weights. The shipping company has a requirement that all items loaded in a container must weigh less than or equal to 4 units plus the weight of the minimum weight item. All items meeting that requirement will be shipped in one container. What is the smallest number of containers that can be contracted to ship the

View Solution →