Question

View site information Pevchometric testing is designed to find JUDICIO VAIT mormation about an applicant that the traditional

jobOffers has the following parameter(s): scores[scores[O]....scores[n-1]]: an array of integers lowerLimit[lowerLimit[O]....

Language: Java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
import java.lang.*;
import java.io.*;


class Main
{
public static int[] jobOffers(int scores[],int lowerLimit[],int upperLimit[]){
int offers[] = new int[lowerLimit.length];
HashMap<Integer,Integer> hm = new HashMap<>();
  
for(int i=0;i<scores.length;i++){
Integer count = (hm.get(scores[i])==null ? 0 : hm.get(scores[i]));
count++;
hm.put(scores[i],count);

}
  
for(int i=0;i<lowerLimit.length;i++){
  
int ll=lowerLimit[i];
int up= upperLimit[i];
int count =0;
if(ll!=up){
for(int j=ll;j<=up;j++){
int addcount = (hm.get(j)==null ? 0 : hm.get(j));
count = count + addcount;
  
}
}
else{
int addcount1 = (hm.get(ll)==null ? 0 : hm.get(ll));
count = addcount1;
}
offers[i]= count;
}
  
return offers;
}
   public static void main (String[] args) throws java.lang.Exception
   {
       // your code goes here
       int n,q;
       Scanner sc = new Scanner(System.in);
       n= sc.nextInt();
       q= sc.nextInt();
       int[] scores = new int[n];
       int[] upperLimit = new int[q];
       int[] lowerLimit = new int[q];
       int[] offers = new int[q];
       for(int i=0;i<n;i++){
       scores[i]=sc.nextInt();
       }
       for(int i=0;i<q;i++){
       lowerLimit[i]=sc.nextInt();
       }
       for(int i=0;i<q;i++){
       upperLimit[i]=sc.nextInt();
       }
       offers = jobOffers(scores,lowerLimit,upperLimit);
       for(int i=0;i<q;i++){
       System.out.println(offers[i]);
       }
   }
}

//code:

W NP import java.util.*; import java.lang. *; import java.io.*; class Main { public static int[] jobOffers(int scores[], int

{ 40 41 42 43 44 45 46 47 48 49 50 51 - 52 53 54 - 55 56 57 - 58 public static void main (String[] args) throws java.lang. Ex

//sample execution:

Custom Input 5 2 1 2 2 3 4 2 1 3 1 Status Successfully executed Date 2020-07-31 19:26:55 Time 0.12 sec Mem 2184.192 kB X Inpu

Add a comment
Know the answer?
Add Answer to:
Language: Java View site information Pevchometric testing is designed to find JUDICIO VAIT mormation about an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language: java An investor opens a new account and wants to invest in a number of...

    Language: java An investor opens a new account and wants to invest in a number of assets. Each asset begins with a balance of O, and its value is stored in an array using 1-based indexing. Periodically, a contribution is received and equal investments are made in a subset of the portfolio. Each contribution will be given by investment amount, start index, end index. Each investment in that range will receive the contribution amount. Determine the maximum amount invested in...

  • Java 8 9m left Jav 27 28 ALL 29 0 Given an integer array, separate the...

    Java 8 9m left Jav 27 28 ALL 29 0 Given an integer array, separate the values of the array into two subsets, A and B, whose intersection is null and where the addition of the two subsets equals the entire array. The sum of values in set A must be strictly greater than the sum of values in set B, and the number of elements in set A must be minimal. Return the values in set A in increasing...

  • LANGUAGE: JAVA An online coin dealer offers bags of coins that are guaranteed to contain at...

    LANGUAGE: JAVA An online coin dealer offers bags of coins that are guaranteed to contain at least one full set. Given a string comprised of lowercase letters in the range ascii[a-z), where each letter represents a coin type, determine the length of the shortest substring that contains at least one of each type of coin. Example: coins = dabbcabcd The list of all characters in the string is (a, b, c, d]. Two of the substrings that contain all letters...

  • Please use Java for this question. ​​​​​​​ Input Format Format for Custom Testing Input from stdin...

    Please use Java for this question. ​​​​​​​ Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function In the first line, there is a single integer n. In the second line, there is a single integer m. In the ph of the next n lines there are m space-separated integers denoting the throw of the initial grid. In the next line, there is a single integer k. In the next line,...

  • What an Executive Summary Is An executive summary is a specific type of document that does...

    What an Executive Summary Is An executive summary is a specific type of document that does two things: it summarizes a research article, and it offers recommendations as to how information from the article can be used. Some long reports can contain an executive summary section, as indicated in the Pearson handbook. Write a 2 pahe Executive Summary In business contexts, an executive summary is always written for a specific purpose: to explain the information in the article to a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT