VISA OA | Staff SE | BLR

visa logo
visa
Staff SE (Backend)BLR6 years
June 29, 20254 reads

Summary

I applied for a Staff SE (Backend) role at VISA and despite having less experience than required by the job description, I received an Online Assessment link. I cleared the OA, but after discussing compensation, I received a rejection email.

Full Experience

Hi Folks,
Applied for Staff SE (Backend) role at VISA. As per JD, it requires 7.5+ YOE, but somehow I got the OA link.

Currently, SSE @ Walmart having 6 YOE.
College: Tier-3

OA

No. of Questions: 4

#1:
Imagine that you have a time machine. You are given an array years. You start in the year years[0]. Next, you need to travel to years[1], then to years[2], and so on. Your task is to calculate the time required to visit all the years from the list in order.

The time required to travel from the year a to the year b is calculated as follows:

  1. 0 hours if A == B
  2. 1 hour if A < B (going forwards in time)
  3. 2 hours if A > B (going backwards in time)

Example:

For years = [2000,1990,2005,2050], the output should be solution(years) = 4. First you go from 2000 to 1990, which requires 2 hours. Then you go from 1990 to 2005, which requires 1 hour. Then you go from 2005 to 2050, which requires 1 hour. In total, you need 2 + 1 + 1 = 4 hours.

For years = [2000,2021,2005], the output should be solution(years) = 3.

Solution:

public int solution(int[] years) {
int totalTime = 0;
for (int i = 1; i < years.length; i++) {
if (years[i] == years[i - 1]) {
totalTime += 0;
} else if (years[i] > years[i - 1]) {
totalTime += 1;
} else {
totalTime += 2;
}
}
return totalTime;
}
#2:
You are given two positive integers a and b as strings, and your task is to return a string of their digit-wise sums.

Add every 'i'th digit of the first string to the 'i'th digit of the second string, both counted from the end. If the 'i'th digit of one of the strings is absent, its sum will be the 'i'th digit of the other string. Return a string of those sums concatenated with each other.

Example: For a = "99" and b = "99", the output should be solution(a, b) = "1818". The sums of both, the first and the second numbers are 18, so the answer is 1818.

For a = "11" and b = "9", the output should be solution(a, b) = "110". The sum of the first numbers from the end is 10, and the sum of the second numbers from the end is 1, so the answer is 110.

Solution:

public static String solution(String a, String b) {
StringBuilder result = new StringBuilder();
int maxLength = Math.max(a.length(), b.length());

    for (int i = 0; i &lt; maxLength; i++) {
        int digitA = (i &lt; a.length()) ? a.charAt(a.length() - 1 - i) - '0' : 0;
        int digitB = (i &lt; b.length()) ? b.charAt(b.length() - 1 - i) - '0' : 0;
        int sum = digitA + digitB;
        result.insert(0, sum);
    }

    return result.toString();

}

#3:
You're given an array of integers representing fruits on a conveyor belt. Your goal is to count how many contiguous subarrays have at least k non-overlapping identical fruit pairs. A pair is formed when two of the same fruit appear in the subarray, and each fruit can be part of only one pair within that subarray.

For example, in the array [1, 3, 3, 1] with k = 1, the valid subarrays include [1, 3, 3], [3, 3, 1], [1, 3, 3, 1], and [3, 3]—each containing at least one valid pair.

Solution:

public static int solution(int[] fruits, int k) {
int n = fruits.length;
int count = 0;

for (int start = 0; start &lt; n; start++) {
    Map&lt;Integer, Integer&gt; freq = new HashMap&lt;&gt;();
    int pairs = 0;

    for (int end = start; end &lt; n; end++) {
        int fruit = fruits[end];
        freq.put(fruit, freq.getOrDefault(fruit, 0) + 1);

        // If the count of a fruit reaches an even number, it means a new pair is formed.
        if (freq.get(fruit) % 2 == 0) {
            pairs++;
        }

        if (pairs &gt;= k) {
            count++;
        }
    }
}
return count;

}

#4:
You are managing a network of distribution centers that handle package deliveries. Each center has a different capacity and must process a certain number of packages before needing a reset.

You are given an array of integers 'centerCapacities' where centerCapacities[i] is a value between 1 and 5 representing the maximum number of packages that the i-th distribution center can process before requiring maintenance.

You are also given an array of strings 'dailyLog' where dailyLog[i] can be one of the following:

  1. "PACKAGE" - a new package arrives for processing
  2. "CLOSURE <j>" - the j-th distribution center temporarily closes for renovations

Packages are sent to centers in sequential order - each center processes as many packages as it can based on its capacity defined by centerCapacities[i] before packages are sent to the next available center. After a complete rotation through all centers (returning to center 0), the capacity of all operational centers is restored to full, but closed centers remain unavailable.

Notes: The distribution system bypasses any closed centers when allocating packages. You can assume at least one center remains operational throughout the process.

Return the index of the distribution center that processed the most packages. If multiple centers processed the same maximum number of packages, return the center with the highest index.

Partially solved this.

Got response from recruiter that OA is cleared. Recruiter asked for expected comp etc and I asked for 45 base. Next day, received rejection mail.

#visa #oa

Interview Questions (4)

Q1
Time Machine Travel Cost
Data Structures & Algorithms
Imagine that you have a time machine. You are given an array years. You start in the year years[0]. Next, you need to travel to years[1], then to years[2], and so on. Your task is to calculate the time required to visit all the years from the list in order.

The time required to travel from the year a to the year b is calculated as follows:

1. 0 hours if A == B
2. 1 hour if A < B (going forwards in time)
3. 2 hours if A > B (going backwards in time)

Example:

For years = [2000,1990,2005,2050], the output should be solution(years) = 4.
First you go from 2000 to 1990, which requires 2 hours.
Then you go from 1990 to 2005, which requires 1 hour.
Then you go from 2005 to 2050, which requires 1 hour.
In total, you need 2 + 1 + 1 = 4 hours.

For years = [2000,2021,2005], the output should be solution(years) = 3.
Q2
Digit-wise Sum of Strings
Data Structures & Algorithms
You are given two positive integers a and b as strings, and your task is to return a string of their digit-wise sums.

Add every 'i'th digit of the first string to the 'i'th digit of the second string, both counted from the end. If the 'i'th digit of one of the strings is absent, its sum will be the 'i'th digit of the other string. Return a string of those sums concatenated with each other.

Example:
For a = "99" and b = "99", the output should be solution(a, b) = "1818".
The sums of both, the first and the second numbers are 18, so the answer is 1818.

For a = "11" and b = "9", the output should be solution(a, b) = "110".
The sum of the first numbers from the end is 10, and the sum of the second numbers from the end is 1, so the answer is 110.
Q3
Subarrays with K Non-overlapping Identical Fruit Pairs
Data Structures & Algorithms
You're given an array of integers representing fruits on a conveyor belt. Your goal is to count how many contiguous subarrays have at least k non-overlapping identical fruit pairs. A pair is formed when two of the same fruit appear in the subarray, and each fruit can be part of only one pair within that subarray.

For example, in the array [1, 3, 3, 1] with k = 1, the valid subarrays include [1, 3, 3], [3, 3, 1], [1, 3, 3, 1], and [3, 3]—each containing at least one valid pair.
Q4
Distribution Centers Package Processing
Data Structures & Algorithms
You are managing a network of distribution centers that handle package deliveries. Each center has a different capacity and must process a certain number of packages before needing a reset.

You are given an array of integers 'centerCapacities' where centerCapacities[i] is a value between 1 and 5 representing the maximum number of packages that the i-th distribution center can process before requiring maintenance.

You are also given an array of strings 'dailyLog' where dailyLog[i] can be one of the following:

1. "PACKAGE" - a new package arrives for processing
2. "CLOSURE <j>" - the j-th distribution center temporarily closes for renovations

Packages are sent to centers in sequential order - each center processes as many packages as it can based on its capacity defined by centerCapacities[i] before packages are sent to the next available center. After a complete rotation through all centers (returning to center 0), the capacity of all operational centers is restored to full, but closed centers remain unavailable.

Notes:
The distribution system bypasses any closed centers when allocating packages.
You can assume at least one center remains operational throughout the process.

Return the index of the distribution center that processed the most packages. If multiple centers processed the same maximum number of packages, return the center with the highest index.
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!