Search Questions

Latest Questions | Page 4

#1

Village Voyage
A computer game "Village Voyage" has N villages (labeled 1 to N) at some distance from each other. The player starts from any village S and travels through all villages in a circular route, returning to the starting village S. Each village provides energy drinks, which are used to travel to the next village. One energy drink allows travel of one unit distance. The player loses if

Asked in: FLIPKART


Buyer: 0
Code Size: 37
#2

Academic Decathlon
Students are being selected for an academic decathlon team at a school. Each student has a skill level, and for a team to be uniform, the difference between any two consecutive skill levels (when arranged in increasing order) must be either 0 or 1.

Your task is to find the maximum possible team size.

Example
skills = [0, 12, 13, 9, 14]
Valid teams, when sorted, ar

Asked in: UBER


Buyer: 0
Code Size: 12
#3

Sum of Arrays
Given two arrays each of length n, arr1 and arr2, in one operation, any two elements of an array can be swapped. This can occur any number of times.

Find the maximum possible sum of i * (arr2[i] - arr1[i]) for all 1 ≤ i ≤ n after rearranging the arrays. Since the maximum possible sum can be large, return the value modulo (10^9 + 7).

Example
n = 4
arr1 = [2, 1, 3, 4]

Asked in: UBER


Buyer: 1
Code Size: 30
#4

Count Swaps During Custom Sorting
Analyze the efficiency of the following sorting algorithm by counting the number of swaps it performs:
For an array arr of size n:
1. Find the smallest pair of indices 0 ≤ i < j ≤ n-1 such that arr[i] > arr[j], where "smallest" means lexicographical ordering of pairs (i1, j1) < (i2, j2) if i1 < i2 or (i1 = i2 and j1 < j2).
2. If no such pair exists, th

Asked in: UBER


Buyer: 1
Code Size: 50
#5

Stacey is coordinating a beach clean-up event with her university's Women in STEM Charity branch. The beach is covered with tin cans of varying weights arranged in a single line, indexed from 0 to n-1.

Stacey uses a scooper that can pick up three adjacent cans at a time. For each selection:

1. She identifies the lightest remaining can, with weight w
2. She uses the scooper to pick up that

Asked in: JPMORGAN


Buyer: 1
Code Size: 22
#6

Perform a series of operations on a given array of integers. Each operation consists of two indices that define a subarray to reverse, inclusive of those indices.

Return the resulting array after all operations have been applied in the specified order.

Example
arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
operations = [[0, 9], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]

In the first operation,

Asked in: JPMORGAN


Buyer: 2
Code Size: 8
#7

Data scientists at Amazon are working on a utility for detecting similar passwords in their security systems. The utility finds anagram patterns in pairs of passwords. A pair of passwords is considered similar if they are anagrams after removing any number of occurrences of at most one character from each password.

Given n pairs of passwords, for each pair, attempt to make them anagrams. Return

Asked in: AMAZON


Buyer: 1
Code Size: 37
#8

To be efficient, Amazon must optimally distribute parcels among their delivery agents. Initially, there are n agents, and the number of parcels assigned to the i-th agent is initialParcels[i]. There are additionalParcels parcels that also need to be shipped. The additional parcels should be assigned such that the maximum number of parcels assigned to any one agent is minimized.

Given an integer

Asked in: AMAZON


Buyer: 2
Code Size: 20
#9

The Amazon warehouse receives a multitude of packages every day, each assigned a unique identifier from 1 to n. The warehouse manager must sort the packages, not by their identifiers, but rather through a specific process defined by a permutation packageSequence that ensures optimal processing.

Initially, the number of sorted packages, sortedCount, is zero. In each operation, the manager sifts

Asked in: AMAZON


Buyer: 6
Code Size: 12
#10

As an operations engineer at Amazon, you are responsible for organizing the distribution of n different items in the warehouse. The size of each product is provided in an array productSize, where productSize[i] represents the size of the i-th product.

You construct a new array called variation, where each element variation[i] is the difference between the largest and smallest product sizes amon

Asked in: AMAZON


Buyer: 1
Code Size: 12