2. Football Scores The number of goals achieved by two football teams in matches in a league is given in the form of two lists. For each match of team B, compute the total number of matches of team A where team A has scored less than or equal to the number of goals scored by team B in that match. Example teamA = [1, 2, 3] teamB = [2, 4] Team A has played three matches and has scored teamA = [1, 2, 3] goals in each match respectively. Team B has played two matches and has scored teamB = [2, 4] goals in each match respectively. For 2 goals scored by team B in its first match, team A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is. [2,3]. Function Description Complete the function counts in the editor below. counts has the following parameter(s): int teamA[n]: first array of positive integers int teamB[m]: second array of positive integers eamB = [2, 4] eam A has played three matches and has scored teamA = [1, 2, 3] goals in each match respectively. Team B has played two matches and has scored teamB = [2, 4] goals in each match respectively. For 2 goals scored by team B in its first match, eam A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is [2,3]. Function Description Complete the function counts in the editor below. counts has the following parameter(s): int teamA[n]: first array of positive integers int teamB[m]: second array of positive integers Return int[m]: an array of m positive integers, one for each teamB[i] representing the total number of elements from teamA[j] satisfying teamA[j] ≤ teamB[i] where Osj< n and 0≤i import java.io.*; ... 14 15 16 17 18 19 20 21 21 22 23 24 25 26 23 24 27 28 29 30 31 32 26 ✪ Info class Result { INTEGER ARRAY. } } /* 27 28 29 30 31 32 public class Solution {... Test Results Java 15 Autocomplete Ready 1>import java.io.*;... public static List counts (List teamA, List teamB) { /* *Complete the 'counts' function below. 14 15 class Result { 16 17 18 19 20 * The function is expected to return an } } * The function accepts following parameters: 1. INTEGER_ARRAY teamA * 2. INTEGER_ARRAY teamB */ at Resul 3 Custom Input *Complete the 'counts' function below. *The function is expected to return an INTEGER ARRAY. Line: 14 Col: public static List counts (List teamA, List teamB) { public class Solution {... 13:11 * The function accepts following parameters: 1. INTEGER ARRAY teamA * 2. INTEGER ARRAY teamB Line: 14 Col: 1 ⠀

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

using java to solve this algorithm problem

2. Football Scores
The number of goals achieved by two football teams in matches in a league is given
in the form of two lists. For each match of team B, compute the total number of
matches of team A where team A has scored less than or equal to the number of
goals scored by team B in that match.
Example
teamA = [1, 2, 3]
teamB = [2, 4]
Team A has played three matches and has scored teamA = [1, 2, 3] goals in each
match respectively. Team B has played two matches and has scored teamB = [2,
4] goals in each match respectively. For 2 goals scored by team B in its first match,
team A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its
second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is.
[2,3].
Function Description
Complete the function counts in the editor below.
counts has the following parameter(s):
int teamA[n]: first array of positive integers
int teamB[m]: second array of positive integers
eamB = [2, 4]
eam A has played three matches and has scored teamA = [1, 2, 3] goals in each
match respectively. Team B has played two matches and has scored teamB = [2,
4] goals in each match respectively. For 2 goals scored by team B in its first match,
eam A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its
second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is
[2,3].
Function Description
Complete the function counts in the editor below.
counts has the following parameter(s):
int teamA[n]: first array of positive integers
int teamB[m]: second array of positive integers
Return
int[m]: an array of m positive integers, one for each teamB[i] representing the
total number of elements from teamA[j] satisfying teamA[j] ≤ teamB[i] where Osj<
n and 0≤i<m, in the given order.
Constraints
• 2 ≤n, m≤ 105
• 1 ≤ teamA[j] ≤ 10%, where 0≤j<n.
• 1 steamB[i] ≤ 10%, where 0 si<m.
::::::::
✪ Info Java 15
Autocomplete Ready Ⓒ
1 > import java.io.*; ...
14
15
16
17
18
19
20
21
21
22
23
24
25
26
23
24
27
28
29
30
31
32
26
✪ Info
class Result {
INTEGER ARRAY.
}
}
/*
27
28
29
30
31
32 public class Solution {...
Test Results
Java 15
Autocomplete Ready
1>import java.io.*;...
public static List<Integer> counts
(List<Integer> teamA, List<Integer> teamB) {
/*
*Complete the 'counts' function below.
14
15 class Result {
16
17
18
19
20
* The function is expected to return an
}
}
* The function accepts following parameters:
1. INTEGER_ARRAY teamA
* 2. INTEGER_ARRAY teamB
*/
at Resul
3
Custom Input
*Complete the 'counts' function below.
*The function is expected to return an
INTEGER ARRAY.
Line: 14 Col:
public static List<Integer> counts
(List<Integer> teamA, List<Integer> teamB) {
public class Solution {...
13:11
* The function accepts following parameters:
1. INTEGER ARRAY teamA
* 2. INTEGER ARRAY teamB
Line: 14 Col: 1
⠀
Transcribed Image Text:2. Football Scores The number of goals achieved by two football teams in matches in a league is given in the form of two lists. For each match of team B, compute the total number of matches of team A where team A has scored less than or equal to the number of goals scored by team B in that match. Example teamA = [1, 2, 3] teamB = [2, 4] Team A has played three matches and has scored teamA = [1, 2, 3] goals in each match respectively. Team B has played two matches and has scored teamB = [2, 4] goals in each match respectively. For 2 goals scored by team B in its first match, team A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is. [2,3]. Function Description Complete the function counts in the editor below. counts has the following parameter(s): int teamA[n]: first array of positive integers int teamB[m]: second array of positive integers eamB = [2, 4] eam A has played three matches and has scored teamA = [1, 2, 3] goals in each match respectively. Team B has played two matches and has scored teamB = [2, 4] goals in each match respectively. For 2 goals scored by team B in its first match, eam A has 2 matches with scores 1 and 2. For 4 goals scored by team B in its second match, team A has 3 matches with scores 1, 2 and 3. Hence, the answer is [2,3]. Function Description Complete the function counts in the editor below. counts has the following parameter(s): int teamA[n]: first array of positive integers int teamB[m]: second array of positive integers Return int[m]: an array of m positive integers, one for each teamB[i] representing the total number of elements from teamA[j] satisfying teamA[j] ≤ teamB[i] where Osj< n and 0≤i<m, in the given order. Constraints • 2 ≤n, m≤ 105 • 1 ≤ teamA[j] ≤ 10%, where 0≤j<n. • 1 steamB[i] ≤ 10%, where 0 si<m. :::::::: ✪ Info Java 15 Autocomplete Ready Ⓒ 1 > import java.io.*; ... 14 15 16 17 18 19 20 21 21 22 23 24 25 26 23 24 27 28 29 30 31 32 26 ✪ Info class Result { INTEGER ARRAY. } } /* 27 28 29 30 31 32 public class Solution {... Test Results Java 15 Autocomplete Ready 1>import java.io.*;... public static List<Integer> counts (List<Integer> teamA, List<Integer> teamB) { /* *Complete the 'counts' function below. 14 15 class Result { 16 17 18 19 20 * The function is expected to return an } } * The function accepts following parameters: 1. INTEGER_ARRAY teamA * 2. INTEGER_ARRAY teamB */ at Resul 3 Custom Input *Complete the 'counts' function below. *The function is expected to return an INTEGER ARRAY. Line: 14 Col: public static List<Integer> counts (List<Integer> teamA, List<Integer> teamB) { public class Solution {... 13:11 * The function accepts following parameters: 1. INTEGER ARRAY teamA * 2. INTEGER ARRAY teamB Line: 14 Col: 1 ⠀
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY