Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Breaking the Records in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Link for the Problem – Breaking the Records – Hacker Rank Solution
Breaking the Records – Hacker Rank Solution
Problem:
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.
Example
Scores are in the same order as the games played. She tabulates her results as follows:
Count Game Score Minimum Maximum Min Max 0 12 12 12 0 0 1 24 12 24 0 1 2 10 10 24 1 1 3 24 10 24 1 1
Given the scores for a season, determine the number of times Maria breaks her records for most and least points scored during the season.
Function Description
Complete the breakingRecords function in the editor below.
breakingRecords has the following parameter(s):
- int scores[n]: points scored per game
Returns
- int[2]: An array with the numbers of times she broke her records. Index is for breaking most points records, and index is for breaking least points records.
Input Format
![Breaking the Records in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 2 image 55](https://technorj.com/wp-content/uploads/2021/12/image-55.png)
Sample Input 0
9 10 5 20 20 4 5 2 25 1
Sample Output 0
2 4
Explanation 0
The diagram below depicts the number of times Maria broke her best and worst records throughout the season:
![Breaking the Records in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 3 Breaking the Records](https://s3.amazonaws.com/hr-assets/0/1487360234-6bca5c518d-breakingbest3.png)
She broke her best record twice (after games and ) and her worst record four times (after games , , , and ), so we print 2 4
as our answer. Note that she did not break her record for best score during game , as her score during that game was not strictly greater than her best record at the time.
Sample Input 1
10 3 4 21 36 10 28 35 5 24 42
Sample Output 1
4 0
Explanation 1
The diagram below depicts the number of times Maria broke her best and worst records throughout the season:
![Breaking the Records in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 4 Breaking the Records](https://s3.amazonaws.com/hr-assets/0/1487360375-aee4388234-breakingbest5.png)
She broke her best record four times (after games , , , and ) and her worst record zero times (no score during the season was lower than the one she earned during her first game), so we print 4 0
as our answer.
Breaking the Records – Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class BreakingTheRecords { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] score = new int[n]; int baseScore = in.nextInt(); int bestScoreCount = 0, leastScoreCount = 0; int baseBestScore = baseScore, baseLeastScore = baseScore; for (int score_i = 1; score_i < n; score_i++) { score[score_i] = in.nextInt(); if (score[score_i] < baseLeastScore) { baseLeastScore = score[score_i]; leastScoreCount++; } if (score[score_i] > baseBestScore) { baseBestScore = score[score_i]; bestScoreCount++; } } System.out.println(bestScoreCount + " " + leastScoreCount); in.close(); } }
It is appropriate time to make some plans for the future
and it is time to be happy. I’ve read this post
and if I could I wish to suggest you some interesting things
or suggestions. Perhaps you could write next articles referring to this
article. I desire to read more things about it!
tadalafil canada buy cialis generic cheapest ed pills
duricef 500mg pills epivir price brand finasteride 5mg
order estradiol generic minipress 2mg sale purchase prazosin sale
generic flagyl 400mg buy keflex 125mg pill purchase cephalexin without prescription
mebendazole order how to buy tretinoin buy tadalafil 10mg without prescription
cleocin 150mg for sale buy cleocin generic top erection pills
buy avanafil cheap avanafil us diclofenac drug
buy generic tamoxifen online cefuroxime 250mg sale purchase ceftin for sale
indocin 75mg us buy cheap generic cefixime cefixime ca
amoxicillin price amoxicillin 250mg cost generic clarithromycin 500mg
catapres 0.1mg sale meclizine online order spiriva 9mcg usa
cheap minocin buy hytrin generic buy actos 30mg without prescription
leflunomide 20mg drug purchase sulfasalazine where to buy sulfasalazine without a prescription
buy accutane generic buy azithromycin for sale azithromycin order
cheap tadalafil tablets order tadalafil 10mg for sale cialis for sales
azipro order buy omnacortil online neurontin 600mg pill
ivermectin for humans new ed drugs prednisone 10mg cheap
buy lasix buy lasix generic order ventolin 4mg pills
order vardenafil pill order hydroxychloroquine 400mg buy plaquenil online
order ramipril 5mg without prescription order altace generic arcoxia 120mg pill
order levitra 20mg generic order hydroxychloroquine 400mg for sale hydroxychloroquine 400mg brand
buy mesalamine medication buy azelastine 10ml generic cost avapro 300mg
benicar us divalproex pills divalproex price
clobetasol drug order cordarone pill buy cheap generic amiodarone
how to get acetazolamide without a prescription azathioprine 50mg us imuran 50mg price
buy lanoxin without a prescription purchase digoxin online molnupiravir oral
naprosyn 500mg tablet cefdinir 300mg pill prevacid 30mg pill
buy generic coreg carvedilol where to buy buy aralen 250mg
order albuterol phenazopyridine 200 mg drug buy pyridium paypal