Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0485918

Browse files
committed
--formatted: Arrays/BreakingTheRecords.java
1 parent d05202d commit 0485918

File tree

3 files changed

+69
-13
lines changed

3 files changed

+69
-13
lines changed

‎Practice Problems/Arrays/Breaking The Record/BreakingTheRecords.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import java.util.concurrent.*;
77
import java.util.regex.*;
88

9-
public class Solution {
10-
9+
public class BreakingTheRecords {
1110

1211
static int[] breakingRecords(int[] scores) {
13-
int[] result = new int[2];
12+
int[] result = new int[2];
1413
int countMax=0, countMin=0 ,max = scores[0], min = scores[0];
1514
for(int i=1; i< scores.length; i++){
1615
if(scores[i] > max){ max = scores[i]; countMax++; }
Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,81 @@
1+
# Breaking The Record
12

2-
# Breaking The Record (Hackerrank)
3+
**Problem from HackerRank**
34

4-
## Problem Statement
55
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.
66

7-
For example, assume her scores for the season are represented in the array Scores= [12,24,10,24] . Scores are in the same order as the games played.
8-
7+
For example, assume her scores for the season are represented in the array `Scores= [12,24,10,24]` . Scores are in the same order as the games played.
98

9+
Count
10+
Game Score Minimum Maximum Min Max
11+
0 12 12 12 0 0
12+
1 24 12 24 0 1
13+
2 10 10 24 1 1
14+
3 24 10 24 1 1
1015

1116
Given the scores for a season, find and print the number of times Maria breaks her records for most and least points scored during the season.
1217

13-
## Function Description
14-
Complete the breakingRecords function in the editor below. It must return an integer array containing the numbers of times she broke her records. Index 0 is for breaking most points records, and index 1 is for breaking least points records.
18+
**Function Description**
19+
20+
Complete the `breakingRecords` function in the editor below. It must return an integer array containing the numbers of times she broke her records. Index 0 is for breaking most points records, and index 1 is for breaking least points records.
1521

1622
breakingRecords has the following parameter(s):
1723

1824
scores: an array of integers
1925

20-
## Input Format
21-
The first line contains n an integer , the number of games.
22-
The second line contains n space-separated integers describing the respective values of score0,score1....
26+
**Input Format**
27+
28+
The first line contains an integer `n` , the number of games.
29+
The second line contains `n` space-separated integers describing the respective values of score<sub>0</sub>, score<sub>1</sub>....
30+
31+
_Output Format_
2332

24-
## Output Format
2533
Print two space-seperated integers describing the respective numbers of times the best (highest) score increased and the worst (lowest) score decreased.
34+
35+
**Constraints**
36+
37+
- 1 <= `n` <= 1000
38+
- 0 <= `scores[i]` <= 10<sup>8</sup>
39+
40+
## Examples
41+
42+
### Example 1
43+
44+
**Input:**
45+
46+
```java
47+
9
48+
10 5 20 20 4 5 2 25 1
49+
```
50+
51+
**Output:**
52+
53+
```java
54+
2 4
55+
```
56+
57+
**Explaination:** The diagram below depicts the number of times Maria broke her best and worst records throughout the season:
58+
59+
<img src="https://s3.amazonaws.com/hr-assets/0/1487360234-6bca5c518d-breakingbest3.png" />
60+
61+
She broke her best record twice (after games **2** and **7** ) and her worst record four times (after games **1**, **4**, **6**, and **8** ), so we print 2 4 as our answer. Note that she did not break her record for best score during game **3**, as her score during that game was not strictly greater than her best record at the time.
62+
63+
### Example 2
64+
65+
**Input:**
66+
67+
```java
68+
10
69+
3 4 21 36 10 28 35 5 24 42
70+
```
71+
72+
**Output:**
73+
74+
```java
75+
4 0
76+
```
77+
78+
**Explaination:** The diagram below depicts the number of times Maria broke her best and worst records throughout the season:
79+
<img src="https://s3.amazonaws.com/hr-assets/0/1487360375-aee4388234-breakingbest5.png" />
80+
81+
She broke her best record four times (after games **1**, **2**, **3**, and **9**) 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.

‎Practice Problems/Arrays/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All questions added here are taken from various sites like GeeksForGeeks, LeetCo
66

77
- [ A Very Big Sum](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/A%20Very%20Big%20Sum)
88
- [Arrange Students](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/Arrange%20Students)
9+
- [Breaking The Records](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/Breaking%20The%20Records)
910
- [Find All Numbers Disappeared In An Array](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/Find%20All%20Numbers%20Disappeared%20In%20An%20Array)
1011
- [Knight's Possible Moves](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/Knight's%20Possible%20Moves)
1112
- [Maximum Subarray](https://github.com/srsandy/Data-Structures-and-Algorithms-in-Java-2nd-Edition-by-Robert-Lafore/tree/master/Practice%20Problems/Arrays/Maximum%20Subarray)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /