maximum cost of laptop count hackerrank solution in c. In this HackerRank Minimum Loss problem solution, Lauren has a chart of distinct projected prices for a house over the next several years. maximum cost of laptop count hackerrank solution in c

 
 In this HackerRank Minimum Loss problem solution, Lauren has a chart of distinct projected prices for a house over the next several yearsmaximum cost of laptop count hackerrank solution in c  Where: - max denotes the largest integer in

S. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. Function Description Complete the function birthdayCakeCandles in the editor below. First we compared a with b , c and d. Sample input: 50 [20,19] [24,20] That means Molly has 50 dollars to spend. Cost 2 * 6 = 12. She must buy the house in one year and sell it in another, and she must do so at a loss. Active Traders. Algorithms Warmup Solve Me First | Problem | Solution | Score: 1; Simple Array Sum | Problem | Solution | Score: 10 We would like to show you a description here but the site won’t allow us. Repeated String HackerRank Solution in C, C++, Java, Python. As an example, the following tree with 4. We would print. Determine the minimum number of moves required to reduce the value of N to 0. Complete the function maximumToys in the editor below. Share this Content. So unless looping creates costs ending with new digits, looping does not have impact on cost. YASH PAL July 17, 2021. Total order of 150 eggs is less than the total number of Eggs 50+15+80+10+5 = 160. Then print the respective minimum and maximum values as a single line of two space-separated long. The possible answers are 40 and 38. The structure of. YASH PAL May 17, 2021. To associate your repository with the hackerearth-solutions topic, visit your repo's landing page and select "manage topics. Each query consists of a single number N. , n] without any duplicates. Example. struct Workshop having the following members: The workshop’s start time. In next second, the timer resets to 2*the initial number for the prior cycle and continues. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. Read program statement to find the Mini-Max Sum Hackerrank Solution in C++. HackerRank & Project Euler Problem 34 Solution: Find the sum of all numbers which are equal to the sum of the factorial of their digits. The top is 3 units. So, the remaining amount is P = 6 – 2 = 4. On day 4, call a worker for 7-day which costs cost [1] = 8, which covers day 4, 5,. This is due to more efficient processors and improved battery chemistry that allow longer usage times. Alice and Bob each created one problem for HackerRank. Use the counting sort to order a list of strings associated with integers. Java MD5 – Hacker Rank Solution. HackerRank solution for Functions in C++, which shows how to use functions in C++ with the proper return type, parameters and definition. Example: Let the array A = [1,2,3,4] Then, we can remove 1 and 2, add both of them and keep the sum back in array. dynamic link library in windows 7; sms farm software; wells fargo employee 401k login; tbn christmas grace . Given a sequence of integers, where each element is distinct and satisfies . If two strings are associated with the same integer, they must be printed in their original order, i. Initially, her luck balance is 0. After going through the solutions, you will be able to understand the concepts and solutions very easily. A tag already exists with the provided branch name. In this post, we will solve HackerRank Highest Value Palindrome Solution. ) Jul 31st 2020, 9:00 am PST. Approach: The person should buy the most expensive item and then start taking the items starting from the least pricing (until the total price is less than or equal to the bought item. So, if the input is like weights = [2, 2, 4, 6] values = [15, 15, 20, 35] capacity = 8 count = 3, then the output will be 50, as we can select first 3 items, since the total. py","path":"Skills. Balanced System Files partition - Problem Solving (Basic) certification | HackerRank. When a programmer submits a solution to a programming challenge, their submission is scored on the accuracy of their output. # # The function is expected to return a LONG_INTEGER. Lisa’s Workbook HackerRank Solution in C, C++, Java, Python. Objective. Given price lists for keyboards and USB drives and a budget, find the cost to buy them. HackerRank is a pre-employment testing solution designed to help businesses of all sizes plan, source, screen, interview, and hire qualified candidates using a centralized dashboard. so here we have n queries that representing the n communities. 0 min read. You signed out in another tab or window. Attending Workshops C++ HackerRank Solution. time limit exceeded hacker rank - max profit if know future prices. The function accepts following parameters:","# 1. Now, we can choose the second and third item and pay for the maximum one which is max (4, 3) = 4, and the remaining amount is 4 – 4 = 0. You have also assigned a rating vi to each problem. Given an n element array of integers, a, and an integer, m, determine the maximum value of the sum of any of its. The directory structure of a system disk partition is represented as a tree. Problem Solving (Basic) certification | HackerRank. For example, the pair (2, 3) is counted for d = 1 and d = 6. Do you have more questions? Check out our FAQ. Dynamic Array in C – Hacker Rank Solution. Aggregation. Explanation 1. Each value of between and , the length of the sequence, is analyzed as follows:Output: 67. The queue of laptops can be more easily viewed as follows: The function accepts following parameters:","# 1. NET initiative, C# is a general-purpose, object-oriented programming language designed for Common Language Infrastructure (CLI), and widely recognized for its structured, strong-typing and lexical scoping abilities. Service Lane HackerRank Solution in C, C++, Java, Python. Given N numbers, count the total pairs of numbers that have a difference of K. The obvious thing to try first is using a transient vector so see if that helps. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. To associate your repository with the hackerrank-c-solutions topic, visit your repo's landing page and select "manage topics. Balance of 70-50 = 20 then adjusted against 15. January 17, 2021 by Aayush Kumar Gupta. Bomberman lives in a rectangular grid. Where: - max denotes the largest integer in. You have to maintain the tree under two operations: Update Operation. Here are some steps you can follow to solve HackerRank problems in C: Read the problem statement: Before you start writing code, make sure you understand the problem and what you need to do to. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. Sherlock and Cost [50p] Sherlock and Squares [20p] Simple Array Sum [10p] Staircase [10p] Subarray Division [10p] Taum and B'day [25p] The Hurdle Race [15p] Time Conversion [15p] Utopian Tree [20p] Viral Advertising [15p] TODO. Solution in Python: #!/bin/python3 import math import os import random import re import sys # # Complete the 'minTime' function below. The RectangleArea class is derived from Rectangle class, i. Sample Input 1. Pick the lower of the two types seen twice: type 1. Recently searched locations will be displayed if there is no search query. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/maximum-cost-of-laptop-count":{"items":[{"name":"test-cases","path. {"payload":{"allShortcutsEnabled":false,"fileTree":{"Skills Certification Test/Problem Solving (Basic)":{"items":[{"name":"Active Traders. There is one other twist: strings in the first half of the. Luckily, a service lane runs parallel to the highway. RectangleArea. Developed around 2000 by Microsoft as part of its . HackerRank Super Maximum Cost Queries problem solution. The declaration of a variadic function starts with the declaration of at least one named variable, and uses an ellipsis as the last parameter, e. You must create an array of length from elements of such that its unfairness is minimized. Function Description. Balanced System File partition. The maximum value obtained is 2. Java Lambda Expressions – Hacker Rank Solution. In each query, you will be given an integer and you have to tell whether that integer is present in. Based on the return type, it either returns nothing (void) or something. The rating for Alice's challenge is the triplet a = (a [0], a [1], a [2]), and the rating for Bob's challenge is the triplet b = (b [0], b [1], b. name, COUNT(c. {"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":". You signed in with another tab or window. There is a strange counter. January 17, 2021 by Aayush Kumar Gupta. Follow the steps to solve the problem: Count the number of 1’s. maximumToys has the following parameter(s): int prices[n]: the toy prices; int k: Mark’s budget; Returns. 2 5 5 2 6 3 4 2 3 1. Think of a way to store and reference previously computed solutions to avoid solving the same subproblem. Otherwise, go to step 2. YASH PAL June 10, 2021. space complexity is O(1). roadsAndLibraries has the following parameters: int n: integer, the number of cities. These solutions demonstrate various concepts and techniques in C++, from basic syntax and data types to advanced algorithms and data. In this post, we will solve HackerRank Largest Permutation Problem Solution. Here, I'm using two stacks, one of which tracks only maximum elements. So, the idea is to iterate a loop M times, and in each iteration find the value of the largest element in the array, and add its value to the profit and then decrementing its value in the array by 1. The product of their areas is 5 x 1 = 5. Let the count of 1’s be m. , Attempts: 349109. Mini-max sum - HackerRank solution in python and C++. Hello coders, in this post you will find each and every solution of HackerRank Problems in C++ language. There is one other twist: strings in the first half of. Mean, Var and Std – Hacker Rank Solution. Say “Hello, World!”. Problem. Sort the given array in increasing order. Input and Output in C++ – Hacker Rank Solution. Write a program to calculate the sum of all the digits of N. Problem. # # The function is expected to return an INTEGER. However, if some defect is encountered during the testing of a laptop, it is labeled as \"illegal\" and is not counted in the laptop count of the day. Hackerrank - Minimum Swaps 2 Solution. The class should have read_input () method, to read the values of width and height of the rectangle. Short Problem Definition: Given two integers, L and R, find the maximal values of A xor B, where A and B satisfies the following condition: L≤A≤B≤R; Link. Sample 1. For example, arr = [1,3,5,7,9]. Here is one question from hackerrank, I have a solution but there is some testcase failed because time limit exceeded. This C++ beginner tutorial uses a HackerRank problem to explain how virtual functions work in C++ between base class. A person wants to determine the most expensive computer keyboard and USB drive that can be purchased with a give budget. e. : number of characters in the name). Explanation: We can buy the first item whose cost is 2. If s [i] is a number, replace it with o, place the original number at the start, and move to i+1. super empath destroy narcissist. HackerRank (Stacks) - Maximum element solution gets a timeout, Hackerrank: Computer Game (max-flow problem with integer factorization), HackerRank woman codesprint: minimum cost Maximum Cost of Laptop Count; Nearly Similar Rectangles; Parallel Processing; Password Decryption; Road Repair; String Anagram; Subarray Sums; Unexpected Demand; Usernames Changes; Vowel Substring; Problem Solving (Intermediate) Bitwise AND; Equalizing Array Elements; File Renaming; Hotel Construction; Largest Area; Maximum Subarray Value; Nice. The Definitive Guide for Hiring Software Engineers. Problem Solving (Basic) Skills Certification Test. Ema built a quantum computer! Help her test its capabilities by solving the problem below. You've arranged the problems in increasing difficulty order, and the i th problem has estimated difficulty level i. Step 3: Then, we used ‘scanf’ function with different format specifiers to read the input. Regular Experession. The RectangleArea class is derived from Rectangle class, i. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/road-repair":{"items":[{"name":"test-cases","path":"certificates/problem. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/longest-subarray":{"items":[{"name":"test-cases","path":"certificates/problem. A valid plus is defined here as the crossing of two segments. Below you can find the Top 25 Hackerrank based coding questions with solutions for the Hackerrank Coding test. August 2023 (4) July 2023 (1) April 2023. in this article we have collected the most asked and most important Hackerrank coding questions that you need to prepare to successfully crack Hackerrank coding round for companies like IBM, Goldman Sachs, Cisco,. Please visit each partner activation page for complete details. In this HackerRank Mini-Max Sum problem solution Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Jan 29, 2016 · Short Problem Definition: You have an empty sequence, and you will be given N queries. In C programming, a variadic function will contribute to the flexibility of the program that you are developing. HackerRank Printing pattern using loops in c problem solution. August 17, 2023 12 min to read HackerRank Algorithms Solutions using Python and C++(CPP) An algorithm is a set of instructions that are used to accomplish a task, such as finding the largest number in a list, removing all the red cards from a deck of playing cards, sorting a collection of names, figuring out an average movie rating from just your friend’s. My public HackerRank profile here. 62%. In order to sell shares on ith day, we need to purchase it on any one of [0, i – 1] days. Maximum Cost of Laptop Count - Problem Solving (Basic) certification | HackerRank Joined Logger - JavaScript (Basic) Certification Test Solution | HackerRank Balanced System Files partition - Problem Solving (Basic) certification | HackerRank 1. Given price lists for keyboards and USB drives and a budget, find the cost to buy them. Solutions to HackerRank problems. In this HackerRank Palindrome Index problem solution, we have given a string of lowercase letters in the range ascii[a-z], to determine the index of a character that can be removed to make the string a palindrome. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. NEW The Definitive Guide for Hiring Software. Download GuideTotal order of 150 eggs is less than the total number of Eggs 50+15+80+10+5 = 160. Complexity: time complexity is O(N^2). Given a very large number, count the frequency of each digit from [0-9]GitHub - kilian-hu/hackerrank-solutions: A collection of solutions to competitive programming Maximum Cost of Laptop Count Nearly Similar Rectangles Maximum Cost of Laptop Count The cost incurred on this day is 2 + 5 + 3 = 10. Call that array . Evaluate skills for any developer role with our Starter, Pro, and Custom pricing plans. Each query is one of these three types: Push the element x into the stack. Absolute distinct count in a sorted array; Check if it is possible to sort an array with conditional swapping of adjacent allowed; Find the maximum cost of an array of pairs choosing at most K pairs; Swap. HackerRank Array reversal problem solution in c. HackerRank Calculate the nth term problem solution in c. 1 min read. ABC->BCA->CAB->ABC. Solutions to problems on HackerRank. Your task is to change it into a string such that there are no matching adjacent characters. The first option will be automatically selected. The first line contains the string s. Given an array of integers, determine whether the array can be sorted in ascending order using only one of the. Request a demo. " If found helpful please press a ⭐. 21%. C++ Class Template Specialization HackerRank Solution. She believes in "saving luck", and wants to check her theory. Therefore some greedy thoughts pop up in my head, and turns out I can proof them, so they become the greedy algorithm which can solved the problem. Count Solutions. A simple solution is consider every subarray and count 1’s in every subarray. HackerRank Digit frequency problem solution in c. Hackerrank Introduction Solutions. With our real-world problem-solving approach, you will gain the practical experience and confidence needed to tackle complex C programming projects. INTEGER dailyCount","#","","def maxCost (cost, labels, dailyCount):"," ans = 0"," cur_cnt = 0"," cur_cost = 0"," for c, l in zip (cost, labels):"," cur_cost += c"," if l == \"illegal\":"," continue"," cur_cnt += 1"," if cur_cnt == dailyCount. # # The function is expected to return a STRING_ARRAY. Variadic functions are functions which take a variable number of arguments. Arrays. System. YASH PAL March 23, 2021. INTEGER dailyCount","#","","def maxCost (cost, labels,. If you like GeeksforGeeks and would like to contribute, you can also write an article using write. Note: This solution is only for reference purpose. Our minimum sum is 1 + 3 + 5 + 7 = 16 and our maximum sum is 3 + 5 + 7 + 9 = 24. a b Feature not available for all Q&As 3. HackerRank Lower Bound-STL solution in c++ programming. HackerRank Maximum Subarray Sum problem solution YASH PAL March 14, 2021 In this HackerRank Maximum Subarray Sum Interview preparation kit problem you have Given an n element array of integers, a, and an integer, m, to determine the maximum value of the sum of any of its subarrays modulo m. The code would return the profit so 3 because you. Each day, you can either buy one share of WOT, sell any number of shares of WOT that you. Ema’s Supercomputer HackerRank Solution in C, C++, Java, Python. Store the prefix sum of the sorted array in pref[]. 7 months ago. Solution – Java Anagrams. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects. Input Format. Start practicing with HackerRank C Program Solutions and take your C. January 17, 2021 by Aayush Kumar Gupta. g. BFS is generally used to find the Shortest Paths in the graph and the minimum distance of all nodes from Source, intermediate nodes, and Destination can be. vscode","contentType. 68%. In this post, we will solve HackerRank The Full Counting Sort Solution. She can buy the keyboard and the USB drive for a total cost of . Area (P3)= 5 units. Super Maximum Cost Queries. You signed in with another tab or window. There is enough good space to color two P3 pluses. Given an array of integers, determine whether the array can be sorted in ascending order. Easy C (Basic) Max Score: 10 Success Rate: 93. vs","contentType":"directory"},{"name":". 1. You need to find the minimum number of swaps required to sort the array in ascending order. Printing Pattern Using LoopsMediumC (Basic)Max Score: 30Success Rate: 95. All these solutions are successfully compiled and passed all the tests. Each is guaranteed to be distinct. # The function accepts following parameters: # 1. {"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"README. I. My Model. It hosts four featured contests every month (Long Challenge, CookOff, LunchTime, and Starters) and gives away prizes and goodies to the winners as encouragement. Get all 44 Hackerrank Solutions C++ programming languages with complete updated code, explanation, and output of the solutions. Hence the Thank you message. Let pos [i] denote the value at position i in permutation P using 1-based indexing. You switched accounts on another tab or window. Feel free to use this solution as inspiration and enhance your knowledge but please don't literally copy and paste the code. In this HackerRank Minimum Loss problem solution, Lauren has a chart of distinct projected prices for a house over the next several years. However, there is a catch. where LAT_N is the northern latitude and LONG_W is the western longitude. An ordered pair can be counted for more than one d. Here , in this code we built a function with a return type int and the function returns the greatest element among the 4 given integers. You are given a square map as a matrix of integer strings. Apart from providing a platform for. Input The first line contains an integer T, the total number of testcases. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/nearly-similar-rectangles":{"items":[{"name":"test-cases","path":"certificates. birthdayCakeCandles has the following parameter (s): int. The last page may only be printed on the front, given the length of the book. Balance of 150-80 = 70 was adjusted against the second highest class of 50. The sides are 4 units. cpp","path":"Problem. Step 2: Then, we created the main function and declared three variables. Take Test. Post Transition in C – Hacker Rank Solution. YASH PAL May 17, 2021. The person can buy any item of price 5 or 6 and download items of prices 1 and 3 for free. When a programmer submits a solution to a programming challenge, their submission is scored on the accuracy of their output. 70% of companies test this subject. YASH PAL July 24, 2021. Function Description. Up to 10 attempts per month. Then follow T lines, each line contains an integer N. Finally return size of largest subarray with all 1’s. In this HackerRank Roads and Libraries Interview preparation kit problem, There are q queries, where each query consists of a map of HackerLand and value of c_lib and c_road. Problem Statement : You're given an integer N. , Mock Tests: 0. Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Maximum Cost of Laptop Count; Nearly Similar Rectangles. Solve overlapping subproblems using Dynamic Programming (DP): You can solve this problem recursively but will not pass all the test cases without optimizing to eliminate the overlapping subproblems. If the book is n pages long, and a student wants to turn to page p, what is the minimum. void min_max (unsigned long int arr []) { unsigned long. A weighted string is a string of lowercase English letters where each letter has a weight. Complete the cost function in the editor below. . Frequent Problems in Coding Tests. To solve Insertion Sort Part 2, we loop from index 1 to the last index and find the position for each index. Maximum Cost of Laptop Count - Problem Solving (Basic. Given an array of non-negative integers, count the number of unordered pairs of array elements such that their bitwise AND is a power of 2. . YASH PAL July 24, 2021. If it is not possible to buy both items, return . ^ Not available for all subjects. BE FAITHFUL TO YOUR WORK. Maximum profit gained by selling on ith day. Knuth, Selected Papers on Computer Science. Submit. Iterate a loop until M > 0, and perform the following steps: Decrease the value. None of the rear faces are exposed. Task. This is where business management consultancy steps in, providing valuable insights and recommendations to improve efficiency, productivity, and overall. HackerRank Toll Cost Digits Problem. Given the price lists for the store's keyboards and USB drives, and Monica's budget, find and print the amount of. return_type function_name (arg_type_1 arg_1, arg. output to STDOUT. A simple solution is consider every subarray and count 1’s in every subarray. Complete the function roadsAndLibraries in the editor below. We define the following terms:Cavity Map HackerRank Solution in C, C++, Java, Python. Find the number of paths in T having a cost, C, in the inclusive range from L to R. HackerRank The Maximum Subarray problem solution. 1. std::sort(array. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for. Check the difference between this removed first element and the new peek element. More than 100 million people use GitHub to discover, fork, and contribute to. Implementation:Our platform provides a range of challenges covering various C programming topics such as arrays, pointers, functions, and more. INTEGER_ARRAY cost","# 2. HackerRank solution for Maximum Element in Stack in C++. Going further, since no number bigger than 2,540,160 is possible, the first. Count how many candles are tallest. Your class should be named. For example, let's say the array is arr = [10, 7, 2, 8, 3), and let '&' denote the bitwise AND operator. She wants to minimize her financial loss. Determine how many squares the queen can attack. Alternating Characters HackerRank Solution in C, C++, Java, Python. HackerRank is the market-leading solution for hiring developers. Each vendor sells the laptops in batches, with a quantity identifying how many laptops on each batch, and a cost for the whole batch. Contribute to RodneyShag/HackerRank_solutions development by creating an account on GitHub. Type at least three characters to start auto complete. Each pair of cities are directly connected by a unique directed road, and each road has its own toll that must be paid every time it is used. Original Value 3, − 1, − 2. println( (ret) ? "Anagrams" : "Not Anagrams" ); Disclaimer: The above Problem ( Java Anagrams ) is generated by Hacker Rank but the Solution is Provided by CodingBroz. HackerRank Solutions Certificates. Maximum Cost of Laptop Count - Problem Solving (Basic) certification | HackerRank Parallel Processing - Problem Solving (Basic) certification | HackerRank Python: Multiset Implementation | HackerRank CertificationGiven a list of prices and an amount to spend, what is the maximum number of toys Mark can buy? For example, if and Mark has to spend, he can buy items for , or for units of currency. It covers basic topics of Data Structures (such as Arrays, Strings) and Algorithms (such as Sorting and Searching). e. What is The Cost Of A Tree Hackerrank. Also, transfer value can't be transferred further. This competency area includes understanding the structure of C#. In this sub-domain, we are going to solve the Introduction hackerrank solutions in the C++ programming language. C, C++, Java, Python, C#. MySQL Solution. Maximum cost of laptop count hackerrank solution in c. Sort by. 3 -Print the maximum element in the stack . all nonempty subsequences. So, he can get at most 3 items. A person wants to determine the most expensive computer keyboard and USB drive that can be purchased with a give budget. January 17, 2021 by Aayush Kumar Gupta. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/password-decryption":{"items":[{"name":"test-cases","path":"certificates. Execution: Based on the constraints, you can search by using brute force. {"payload":{"allShortcutsEnabled":false,"fileTree":{"Problem Solving (Basic) Skills Certification Test":{"items":[{"name":"1. Cost. Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Problem Solving. We define a subarray as a contiguous subsequence in an array. After going through the solutions, you will be able to understand the concepts and solutions very easily. Ex: #5 [Solved] Day 4 Class vs. If two strings are associated with the same integer, they must be printed in their original order, i. We would like to show you a description here but the site won’t allow us. In order to sell shares on ith day, we need to purchase it on any one of [0, i – 1] days. N which you need to complete. {"payload":{"allShortcutsEnabled":false,"fileTree":{"certificates/problem-solving-basic/maximum-cost-of-laptop-count":{"items":[{"name":"test-cases","path. Reload to refresh your session. HackerRank Roads and Libraries Interview preparation kit solution. Consider a matrix where each cell contains either a or a . {"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"Maximum cost of laptop count (C++)","path":"Maximum cost of laptop count (C++)","contentType. See Challenges. Jul 19, 2022 · The logic to Mini-Max Sum Hackerrank Solution in C++ The First step is to take an input from the user and after that take another variable to add all 5 number of an array and store the sum of 5 variable in sum name variable for better understanding let's take an example to suppose array 5 elements are 2, 5, 1, 4, 3 Sample Output 2. Disclaimer: The above Problems are generated by Hacker Rank but the Solutions are Provided by CodingBroz.