1. Question 1
You've just started as a trainer in Thoughtworks University, and you want to make a good first impression. You start investigating how to make it easier to organise the coding sessions. It turns out that trainers are spending a lot of their time finding out the average confidence of the participants.
The coding sessions are organised based on how confident the participants are
Asked in: Siemens
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 sorterOrder that ensures optimal processing.
Initially, the number of sorted packages, sortedCount, is zero. In each operation, the manager sifts thro
Asked in: Amazon
2. Code Question 2
In Amazon's vast inventory system, there's a need to ensure the efficient organization of product codes, represented by the sequence productSeq.
The product codes are categorized using characters 'a' through 'g'. For better management, a substring of product codes is considered valid if the count of each character within the substring does not exceed the number of distinct
Asked in: Amazon
The data engineers at Amazon are working on partitioning their server chains. There is a linear chain of n servers numbered from 1 to n, where the cost parameter associated with the ith server is represented by the array cost[i]. These servers need to be partitioned into exactly k different server chains. The cost of partitioning a server chain servers[i : j] is defined as cost[i] + cost[j]. The t
Asked in: Amazon
1. Simple Text Queries
In this challenge, you will be given an array of sentences and an array of queries. Determine which
sentences contain all of the words of a query. If no sentence contains all of the words, the answer to
that query is [-1].
Example:
sentences = ['bob and alice like to text each other', 'bob does not like to ski but does not like to fall',
'Alice likes to ski']
que
Asked in: Flipkart
Solution
In a lively car showroom, an array of cars awaits, each with its distinctive features. Picture yourself mixing and matching these cars in unique
combinations to create dream blends which have an F-score equal to the XOR value of the combination.
Your mission: To compute the blend score, which is the XOR of the F-score values for all these dreamy combinations.
Now, it's time to r
Asked in: Unstop
Solution
Rahul has an integer array called 'arr' of length N containing unique values. He wants to create a balanced tree where each parent node has
smaller valued nodes on its left and larger valued nodes on its right. This balanced tree should ensure that the depth of the two subtrees for every
node doesn't differ by more than one.
Your task is to assist him in creating this type of tree
Asked in: Unstop
Problem Statement
You have a budget of x coins each day to buy beer, and your goal is to buy as many bottles of beer as possible before the price of beer in all shops exceeds your daily budget.
There are N shops, and each shop sells one bottle of beer per day. The price of beer in each shop increases by 1 coin per day after each purchase.
You can visit multiple shops in a single day, but you
Asked in: Unstop
A substring is a group of contiguous characters in a string. For instance, all substrings of abc are [a, b, c, ab, bc, abc].
Given a binary representation of a number, determine the total number of substrings present that match the following conditions:
1. The 0s and 1s are grouped consecutively (e.g., 01, 10, 0011, 1100, 000111, etc.).
2. The number of 0s in the substring is equal to the n
Asked in: Cognizant
How to Attempt?
Chocolate Arrangement
Alex loves chocolate a lot. His brother Sam gifts him 2^N boxes of chocolate. These boxes are arranged in 2 rows denoted by 2 arrays A and B both of size N. Each box of chocolate contains some number of chocolates which is represented by A[i] and B[i] (for 1 <= i <= N).
Alex wants the boxes of chocolate in those 2 rows to be arranged in such a way that the
Asked in: Siemens