Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,745 views
in Online Assessments by Expert (108,170 points) | 1,745 views

1 Answer

0 like 0 dislike
  1. Reshelving Packets -

 

Range of shelves from 1 to 99 inclusive
Given list of integers, reshelve them to the minimum value possible and return the array in the same order though.

 

Example 1 - Input : [1, 12, 4, 12] - List of shelves
Output - [1, 3, 2, 3]

 

Explanation - Strarting shelf is 1, so that remains same, next lowest available value is 2, which can be assigned to 4 and the next available shelf is 3 that can be assigned to 12.

 

Example 2 - Input : [1, 2, 6, 5]
Ouput : [1, 2, 4, 3]

 

  1. Similar Order -

 

Given List of String represnting each order, from 2 customers, and each character in the order representing item, find if orders were similar.
Conditions for being similar, should be same in length and number of distinct characters should not be more than 3.

 

Example - Input :
x : ["nnbnnb", "ammxdf"]
y : ["bbncbb", "aecxdf"]

 

Output : ["YES", "NO"]

 

x[0] is similar to y[0] as both same in length and
x[0] has 4 "n", y[0] has 1 "n", so delta is 3,
x[0] has 2 "b", y[0] has 2 "b", so delta is 2,
x[0] has 0 "c", y[0] has 1 "c", so delta is 1

 

***Personal note - You would better understand this, if you sort both strings, then difference is only in 3 letters, not more than 3, hence both strings are similar

 

  1. Minimum User Log -

 

Given list of strings which are logs and an integer representing maximum time, determine which user has activity time of less than or equal to the maximum time. Sort and return those list of users.[Do not remember if sorting was asked based on user number or their activity time]

 

Input :
logs : ["12 10 sign-in", "5 100 sign-out", "12 20 sign-out", "5 10 sign-in", "8 20 sign-in", "8 50 sign-out"]
maximumTime : 30

 

Output : [8, 12]

 

Explanation -
User 12 - logged in time period - (signout time - signin time) - 20 - 10 = 10 < 30
User 5 - logged in time period - (signout time - signin time) - 100 - 10 = 90 > 30
User 8 - logged in time period - (signout time - signin time) - 50 - 20 = 30 == 30

by Expert (108,170 points)