In Salesforce's annual hackathon, employees from a team are ranked based on their efficiency scores. These scores are represented as an array. The team lead wants to analyze subgroups of employees to identify groups with specific characteristics. Given: · n employees in a team standing in a line, · An array efficiency representing each employee's efficiency, and · An integer k (1 ≤ k ≤ n), represe
Asked in: SALESFORCE
One block
You are working in the resource distribution team of your company. A One block is a block of data having exactly one resource which has value 1. You are given an array Arr containing Nresource values.
What is the number of ways to divide the array into continuous blocks such that each block is One block.
NOTE - If we cannot form a block with One block, then output 0
Function descri
Asked in: SHARECHAT
Recursive Land Division
A country consists of N regions, each containing a specific number of towns. The government has decided to split the country into two separate nations in a way that minimizes the absolute difference between the total number of towns in each new nation.
Each region is connected to another region through roads, forming a tree structure (i.e., an undirected connected gra
Asked in: SHARECHAT
Task
Calculate the number of pairs of investment (i, j) such that the return is a perfect square.
Example 1
Assumptions
Input
N = 4
Output: 6
Approach
(1, 1), (1, 4), (2, 2), (3, 3), (4, 1), and (4, 4) are the possible pairs.
Square Investment
Bob and John both have N dollars each and want to invest some money in Jack.
They will invest amounts i, j (1 ≤ i, j ≤ N). Jack has promised th
Asked in: SHARECHAT
Your team at Amazon is working on a system that divides applications to a mixed cluster of computing devices. Each application is identified by an integer ID, requires a fixed non-zero amount of memory to execute, and is defined to be either a foreground or background application. IDs are guaranteed to be unique within their own application type, but not across types.
Each device should be assi
Asked in: AMAZON
Amazon's Alexa team is working on optimizing the customer experience for scenarios where customers ask generic questions.
One example of a generic question is "What are good vegetarian restaurants nearby?"
In this example, Alexa would then search for a list of vegetarian restaurants in the city and select the nearest X vegetarian
restaurants relative to the customer's location. Given an ar
Asked in: AMAZON
A student is preparing for a scholarship test which is organized on the Amazon Academy platform and scheduled for next month.
There are n chapters to be studied where the ith chapter has pages[i] pages. In one day, the student decides to read up to p of the remaining pages, each from some k consecutive chapters. Thus, the number of pages remaining to be read is reduced by p from each of these cha
Asked in: AMAZON
Database security and authentication have become vital due to the increasing number of cyberattacks every day.
Amazon has created a team for the analysis of various types of cyberattacks. In one such analysis, the team finds
a virus that attacks the user passwords. The virus designed has an attacking rule defined by attackOrder, which is
a permutation of length n. In the ith second of the at
Asked in: AMAZON
Given two servers and the time taken to upgrade each server in seconds, denoted by t1 and t2 respectively, in one second, one server undergoes the upgrade process. The servers receive requests at certain time intervals and pause upgrades during those seconds. The servers receive requests at multiples of req1 and req2 respectively. Determine the minimum total time (in seconds) required to upgrade
Asked in: EXPEDIA
Given a set of nodes and a list of connected pairs, determine the order (number of nodes) in each connected component in the graph. For each component, calculate the ceiling of the square root of its order, and return the sum of these values across all connected components.
Example
graph_nodes = 10
graph_from = [1, 1, 2, 3, 7]
graph_to = [2, 3, 4, 5, 8]
There are graph_edges = 5 ed
Asked in: UBER