Find All Combination of Numbers that Sum to a Target - Company-specific OAs / Amazon OA

What is even the question

why don’t you guys post the question and explanation. Without these two its hard to understand the solution.

its really irritating to understand without questions and without explanation

Is it the question: ?


Please add the link to the leet code problem to this page. Thanks.

this feels like a scam already…if you’re going to post a problem, post the description and a solution walkthrough. What the hell am I paying for here.

Question is missing.

Please put Question and Solution explanation

Problem description:
A customer wants to buy a pair of jeans, a pair of shoes, a skirt, and a top but has a limited budget in dollars. Given different pricing options for each product, determine how many options our customer has to buy 1 of each product. You cannot spend more money than the budgeted amount.
priceOfJeans = [2, 3]
priceOfShoes = [4]
priceOfSkirts = [2, 3]
priceOfTops = [1, 2]
budgeted = 10
The customer must buy shoes for 4 dollars since there is only one option. This leaves 6 dollars to spend on the other 3 items. Combinations of prices paid for jeans, skirts, and tops respectively that add up to 6 dollars or less are [2, 2, 2], [2, 2, 1], [3, 2, 1], [2, 3, 1]. There are 4 ways the customer can purchase all 4 items.
Function Description
Complete the getNumberOfOptions function in the editor below. The function must return an integer which represents the number of options present to buy the four items.
getNumberOfOptions has 5 parameters:
int[] priceOfJeans: An integer array, which contains the prices of the pairs of jeans available.
int[] priceOfShoes: An integer array, which contains the prices of the pairs of shoes available.
int[] priceOfSkirts: An integer array, which contains the prices of the skirts available.
int[] priceOfTops: An integer array, which contains the prices of the tops available.
int dollars: the total number of dollars available to shop with.
1 ≤ a, b, c, d ≤ 103
1 ≤ dollars ≤ 109
1 ≤ price of each item ≤ 109
Note: a, b, c and d are the sizes of the four price arrays

import java.util.*;
public class Solution
public static int shoppingOptions(int[] pants, int[] shirts, int[] shoes, int[] skirts, int budget)
int answer = 0;

    int X = pants.length;
    int Y = shirts.length;
    int[] sumOfPantsShirts = new int[X*Y];
    int counter = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            sumOfPantsShirts[counter] = pants[i] + shirts[j];
    for (int i = 0; i < shoes.length; i++) {
        for (int j = 0; j < skirts.length; j++) {
            int remainingAmount = budget - shoes[i] - skirts[j];
            answer += getSmallerNumbers(sumOfPantsShirts, remainingAmount);
    return answer;

private static int getSmallerNumbers(int[] arr, int target) {
    int left = 0;
    int right = arr.length;
    while (left < right) {
        int mid = (left + right) / 2;
        if (arr[mid] <= target) {
            left = mid + 1;
        } else {
            right = mid;
    return left;


I don’t understand what question is this. :confused: