# CategoryCoding Challenge

## HackerRank âFind Digitsâ Solution

H

Short Problem Definition: You are given an integer N. Find the digits in this number that exactly divide N (division that leaves 0 as remainder) and display their count. For N=24, there are 2 digits (2 & 4). Both of these digits exactly divide 24. So our answer is 2. Link Find Digits Complexity: time complexity is O(N); space complexity is O(1) Execution: Just follow the problem description. The...

## HackerRank âClimbing The Leatherboardâ Solution

H

Short Problem Definition: Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking. The game uses Dense Ranking, so its leaderboard works like this: The player with the highest score is ranked number 1 on the leaderboard. Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately...

## HackerRank âClosest Numbersâ Solution

H

Short Problem Definition: Given a list of unsorted integers, A={a1,a2,âŚ,aN}, can you find the pair of elements that have the smallest absolute difference between them? If there are multiple pairs, find them all. Link Closest Numbers Complexity: time complexity is O(n*log(n)) // sorting space complexity is O(n) Execution: Just sort the array and print the smallest difference. Solution: 1 2 3 4 5 6...

## HackerRank âCommon Childâ Solution

H

Short Problem Definition: Given two strings a and b of equal length, whatâs the longest string (S) that can be constructed such that it is a child of both? A string x is said to be a child of a string y if x can be formed by deleting 0 or more characters from y. Link Common Child Complexity: time complexity is O(N*M) space complexity is O(N*M) Execution: This is a longest common subsequence...

## HackerRank âCompare Tripletsâ Solution

H

Short Problem Definition: Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100  for three categories: problem clarity, originality, and difficulty. Link Compare Triplets Complexity: time complexity is O(1) space complexity is O(1) Execution: This is a warmup. Follow specification. Solution: [rust]use...

## HackerRank âCount Luckâ Solution

H

Short Problem Definition: Hermione Granger is lost in the Forbidden Forest while collecting some herbs for a magical potion. The forest is magical and has only one exit point, which magically transports her back to the Hogwarts School of Witchcraft and Wizardry. Link Count Luck Complexity: time complexity is O(n) space complexity is O(n) Execution: I solve this challenge using DFS and dynamic...

## HackerRank âCounter Gameâ Solution

H

Short Problem Definition: Louise and Richard play a game. They have a counter set to N. Louise gets the first turn and the turns alternate thereafter. In the game, they perform the following operations. If N is not a power of 2, reduce the counter by the largest power of 2 less than N. If N is a power of 2, reduce the counter by half of N. The resultant value is the new N which is again used for...

## HackerRank âCounting Valleysâ Solution

H

Short Problem Definition: 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 n steps. For every step he took, he noted if it was an uphill, U, or a downhill, D step. Garyâs hikes start and end at sea level and each step up or down represents a 1 unit change in altitude. Link Counting Valleys...

## HackerRank âCut the sticksâ Solution

H

Short Problem Definition: You are given N sticks, where each stick has the length of a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick. Link Cut the sticks Complexity: time complexity is O(n*log(n)) space complexity is O(n) Execution: Cutting every stick will result in O(N^2) which is not required. Sorting the...

## HackerRank âBreaking The Recordsâ Solution

H

Short Problem Definition: Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there. Link Breaking The Records Complexity:...