Hackerrank Minimum Distances (C++)
C++ : Explanation: First, assign a large number to maxInt and assign it to minDist. In this case, we use the largest possible int, 2,147,483,647. Using a double nested for loop, loop through...
C++ : Explanation: First, assign a large number to maxInt and assign it to minDist. In this case, we use the largest possible int, 2,147,483,647. Using a double nested for loop, loop through...
C++ : Explanation: First, check if y2 is greater than y1. If yes, it means the book was returned at a non expired date, and fineAmount is set to 0. Else, if the...
C++ : Explanation: This question involved rotating the elements in a vector. The good thing is, C++ has a nice little in-built function to do that. First, we take mod k by a.size(),...
C++ : Explanation: This question basically deals with getting individual digits from a number with mod (%) and integer division. In the while loop, we will loop till nHolder (temporary holder for n)...
C++ : Explanation: Note: Test case 8 (Test case 1 in Run Code, Test case 8 in Submit Code) is bugged! I spend hours trying to cater to test case 8 but to...
C++ : Explanation: Note: This is a terrible, terrible solution. Look at the number of nested loops! Yes, it works, but loopsss! The question was not easy to understand, so the breakdown is...
C++ : Explanation: It is tempting to simply use an outer for loop (to pass candy around the prisoners), then followed by an inner while loop (to subtract prisoners after each round if...
C++ : Explanation: At first glance, this question feels like a pyramid scheme. The for loop in this case does exactly like what the question says: It first gets the number of likes...
C++ : Explanation: Using the supplied i and j in the for loop, for each i smaller or equal to j, set day = i and reverseDay = 0. Each number will need...
C++ : Explanation: This one is simply. Set the return string cancelled to “YES” as default, and number of on time student onTime to 0. For each element in vector a, if the...