Salesforce LMTS OA [Hyderabad]
Summary
I took a Salesforce LMTS online assessment in Hyderabad, solved one of the two questions but failed on the second due to a timeout, and did not clear the round.
Full Experience
Recently gave salesforce LMTS OA on HackerRank. It's a 75‑mins test, need to solve 2 questions
Q1: generate binray strings
Given an array of integers return list consist of 2 binray strings based on below conditions
- if the integer at current index exists after the index anywhere in the array give 1 to the current index else 0 (seen after)
- if the integer at current index exists before the index anywhere in the array give 1 to the current index else 0 (seen before)
Eg: Arr = [1,2,3,1,2,4,5]
output: {[1100000], [0001100]}
Q2: read logs to update number of pods (bit lengthy question to read andunderstand)
We have n microservices with number of pods active for each service given in integer array. Given m logs as List<List> where each will have 3 entries
log structure - [timestamp, podIndex, newValue for number of pod instances]
based on we logs can perform below 2 operations:
- [1,2,5] - number instances of pod number 2 should be update to 5
- [2,-1,8] - all pods whose instances value is less than 8 should be updated to 8
Eg: n= 4 pods = [1,2,3,4] m= 3 logs = {[1,-1,3], [2,2,20], [1,-1,1]}
output: pods = [3,20,3,4]
(my observations: timestamp given in logs is irrelavant to solve this and pod number in logs is index 1 based)
finished Q1 with all tests passed, Q2 failed few tests due to timeout issue. implemented a optimized solution for Q2 using priority queue but couldn't submit as test timed out before running the code. I couldn't clear the round, hope it helps someone else
Interview Questions (2)
Generate Binary Strings Based on Array Occurrences
Given an array of integers, return a list consisting of two binary strings. For each index:
- If the integer at the current index appears anywhere after this index in the array, set the corresponding bit in the first string to 1, otherwise 0 ("seen after").
- If the integer at the current index appears anywhere before this index in the array, set the corresponding bit in the second string to 1, otherwise 0 ("seen before").
Example
Arr = [1, 2, 3, 1, 2, 4, 5]
output: ["1100000", "0001100"]
Update Pod Instances from Log Operations
We have n microservices, each with a number of active pod instances given in an integer array pods. We also have m log entries, each represented as a list of three integers [timestamp, podIndex, newValue]. Two types of operations can be performed based on the log entry:
[1, i, v]– set the number of instances of podi(1‑based index) tov.[2, -1, v]– update all pods whose current instance count is less thanvtov.
Example
n = 4
pods = [1, 2, 3, 4]
logs = [[1, -1, 3], [2, 2, 20], [1, -1, 1]]
output: [3, 20, 3, 4]
(Note: timestamps are irrelevant for solving the problem.)