UIPath Onsite Interview

Round 1 : https://leetcode.com/problems/escape-a-large-maze/

Round 2: Rank of all elements in an array
Given an array of N integers with duplicates allowed. All elements are ranked from 1 to N in ascending order if they are distinct. If there are say x repeated elements of a particular value then each element should be assigned a rank equal to the arithmetic mean of x consecutive ranks.

Input : 20 30 10
Output : 2.0 3.0 1.0

Input : 10 12 15 12 10 25 12
Output : 1.5, 4.0, 6.0, 4.0, 1.5, 7.0, 4.0

Explanation:
10 is the smallest and there are two 10s so take the average of two consecutive ranks 1 and 2 i.e. 1.5 .
Next smallest element is 12. since, two elements are already ranked, the next rank that can be given is 3.
However, there are three 12’s so the rank of 2 is (3+4+5) / 3 = 4.
Next smallest element is 15. There is only one 15 so 15 gets a rank of 6 since 5 elements are ranked.
Next element is 25 and it gets a rank of 7.

Input : 1, 2, 5, 2, 1, 60, 3
Output : 1.5, 3.5, 6.0, 3.5, 1.5, 7.0, 5.0
Round 3: Behavioural Questions

Round 4: Design a chat server for group chat and implement API to deliver eventual consistency data model

Round 5: Relevance Score Calculator
Given an array of strings calculate the relevancy score for each pair of string in the array.

input: {“abcd”, “dab”, “ba”}
output: {2, 1, 1}

Explanation:
Compare pairs “abcd” and “dab” first in these 2 strings, maximum length of consicutive elemnts is 2 i.e ab
note that we only want to calculate the score for consicutively matching characters so
dab -> d, a, b, da, ab
if we check the above substrings with the string “abcd” then “ab” is the matching substring with largest length for
this pair so the score is 2 for the 1st pair.

For “abcd” and “ba” the max score is 1 since
ba -> b, a

Similarly, for “dab” and “ba” max relevancy score is 1 as there are no 2 consicutive letters in any substrings.