Posts

No Idea hackerrank solution

Image
Hi, Here I solve the No Idea hackerrank solution in Python. Problem - No Idea hackerrank solution There is an array of   integers. There are also    disjoint sets ,   and  , each containing   integers. You like all the integers in set   and dislike all the integers in set  . Your initial happiness is  . For each   integer in the array, if  , you add   to your happiness. If  , you add   to your happiness. Otherwise, your happiness does not change. Output your final happiness at the end. Note:  Since   and   are sets, they have no repeated elements. However, the array might contain duplicate elements. Constraints Input Format The first line contains integers   and   separated by a space. The second line contains   integers, the elements of the array. The third and fourth lines contain...

Counting Valleys Hackerrank Solution In C

Image
Here is How you can solve the  Counting Valleys Hackerrank Solution In C . Problem: Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike, he took exactly   steps. For every step he took, he noted if it was an  uphill ,  , or a  downhill ,   step. Gary's hikes start and end at sea level and each step up or down represents a   unit change in altitude. We define the following terms: A  mountain  is a sequence of consecutive steps  above  sea level, starting with a step up from sea level and ending with a step  down  to sea level. A  valley  is a sequence of consecutive steps  below  sea level, starting with a step down from sea level and ending with a step  up  to sea level. Given Gary's sequence of  up  and  down  steps during his last hike, find and pri...