Uber OA - Senior Software Engineer
Anonymous User
3988

Here are questions from my Uber OA.

4 total questions , 1 hr 10 min total time.

Question 1 : Given an input array -arr[],divide the elements in to two different arrays - first[], second[] where first[0] = arr[0] , second[0] = arr[1] from arr[i] (i > 1) , the elem goes to first[] if the number of elems in first[] greater than arr[i] is greater than number of elements in second[] greater than arr[i] and viceversa. Return the final array with elements in first[] followed by second[].

Question 2: There are two input strings s1,s2. Return true if for every i in s2[i] the char at s2 is the next char in the alphabet sequence for s1[i]. 'z' is considered as next in sequence for 'a'.

Eg: s1 = "ack", s2 = "bdl"; ans: true
s1 = "ack", s2 = "cdl"; ans: false
s1 = "ackz", "bdla"; ans = true

Question: 3

Given a list of words and a matrix with characters, find in how many ways can we form the given list of words using the characters from the matrix. you can move left and down in the matrix from a starting point and see if a word can be formed using that sequence. You can only switch your direction once in the sequence.

eg:
matrix =
[w, o, a , k]
[r , r, a, m]
[e, d, e, r]

String[] words = {"word","order","worder"} ; ans = 2
"Worder" is not part of the ans because you'd need to change the direction twice in the sequence.

Question 4:
Given a list of strings - String[] input, find how many pairs of strings have a prefix in common. input[i] and input[j] is a pair if they have a prefix in common and i < j.

eg: s1 = ["leet", "codechef"], s2= ["leetcode","code","chef"]; ans = 2 ( pair 1 - "leet", "leetcode" and pair 2 - "codechef", "code")

PS. I will update the post with links if I find any similar questions on leetcode.

Comments (11)