Posts

Showing posts from October, 2018

Viral Advertising - HackerRank.

Image
NOTE:   If you are copying my code then its an advice to you to copy it after downloading it to avoid any kind of compilation error its link is available at the bottom of the source code. HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly   people on social media. On the first day, half of those   people (i.e.,  ) like the advertisement and each shares it with   of their friends. At the beginning of the second day,   people receive the advertisement.

Sock Merchant - HackerRank.

Image
NOTE:  If you are copying my code then its an advice to you to copy it after downloading it to avoid any kind of compilation error its link is available at the bottom of the source code. John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are   socks with colors  . There is one pair of color   and one of color  . There are three odd socks left, one of each color. The number of pairs is  . Function Description Complete the  sockMerchant  function in the editor below. It must return an integer representing the

Divisible Sum Pairs - HackerRank.

Image
You are given an array of   integers,  , and a positive integer,  . Find and print the number of   pairs where   and   +   is divisible by  . For example,   and  . Our three pairs meeting the criteria are   and  . Function Description

Designer PDF Viewer - HackerRank.

Image
When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: In this challenge, you will be given a list of letter heights in the alphabet and a string. Using the letter heights given, determine the area of the rectangle highlight in   assuming all letters are   wide. For example, the highlighted  . Assume the heights of the letters are   and  . The tallest letter is   high and there are   letters. The hightlighted area will be   so the answer is  .