Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

API Key Info Your API key is dd927d078678291d8efcf7381fe1. The key you get here

ID: 3598833 • Letter: A

Question

API Key Info

Your API key is dd927d078678291d8efcf7381fe1.

The key you get here will be used to authorize you to access the partner and results APIs.

It’s your first day at a company, and you’re in charge of writing the logic to send invitations to a special two-day event in each country for the company’s partners in those countries. We need to find the dates that’ll work best based on survey results that partners have sent in and determine how many people can attend.

You’re provided with an API that gives you a list of partners, their countries, and which dates they’re available in ISO 8601 format.

Another team will send out the invitations, but you need to tell them when we should host the event and who should attend by POSTing to an API.

The date you send in for the country should be the starting date of the two day period where the most partners can make it for both days in a row. In case of multiple dates with the same number of partners, pick the earlier date. If there are no two days in a row when any partners can make it, return null.

API Docs and Example

To get the list of partners, send an HTTP GET to:

https://candidate.hubteam.com/candidateTest/v2/partners?userKey=dd927d078678291d8efcf7381fe1

Here's a sample response with 10 partners:

POST a JSON body to:

https://candidate.hubteam.com/candidateTest/v2/results?userKey=dd927d078678291d8efcf7381fe1

For the list of partners above, the proper API response to send would look like this:

If your answer is correct, the API will return 200 OK. If the request is malformatted or incorrect, the API will return 400 along with a message indicating if the response is of the wrong structure or incorrect.

If you get a 5xx response, let us know and we'll help you out.

Explanation / Answer

package com.one;

public class X00000000 extends Polynomial {

public static void main(String args[]) throws Exception {

Polynomial p = new X00000000(" X^5"), q = new X00000000("X^2 - X + 1");

Utility.run(p, q);

}

public X00000000(String s) {

// parse string character by character

double coef = 0; // coefficient of term

int deg = 0; // degree of term

String[] terms = s.split(" ");

for (int i = 0; i < terms.length; i++) {

String term = terms[i];

// System.out.println("term:"+term);

String prevTerm = "";

if (i != 0)

prevTerm = terms[i - 1];

if (term.startsWith("X")) {

if (term.length() == 3 && term.contains("^")) {

coef = 1;

deg = Integer.parseInt(term.substring(2));

} else if (term.length() == 1) {

deg = 1;

if (prevTerm.equals("-"))

coef = -1;

else

coef = 1;

}

} else if (term.startsWith("-") || term.startsWith("+"))

continue;

else if (term.length() == 1 && Character.isDigit(term.charAt(0))) {

coef = Integer.parseInt(term);

if (prevTerm.equals("-"))

coef *= -1;

deg = 0;

}

Term T = new Term(coef, deg);

if (data.isEmpty()) {

data.addFirst(T);

} else {

data.addLast(T);

}

}

}

public X00000000() {

super();

}

public Polynomial add(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial subtract(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial multiply(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial divide(Polynomial p) throws Exception {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial remainder(Polynomial p) throws Exception {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote