Visa's latest OA questions.
Three questions in total: the first two were fundamental questions, and the third was an intermediate question.
Question 1
I don't remember the problem statement clearly. It was fairly basic; I remember you needed a hashmap optimization to avoid TLE.
Question 2
Given an integer array (a vector). For each integer in the array, find the minimum k such that:
- It is a positive integer.
- It can be split into a sum of k numbers.
- One of those numbers is 1, 2, or 3.
- The other k - 1 numbers are all even powers of 2 (2 to the power of 0 not included).
If it can't be satisfied, return -1.
Question 3: Shortest prefix needed to construct the permutations
Given a string s made up only of the digits 0-9, and an array of strings (all made up of the characters 0-9). For each string target in the array, find the length of the shortest substring of s starting from index 0 such that the characters in that substring can be used to construct all permutations of target. Return an array of the substring lengths.
Discussion
Loading comments…