cswork / libraryOpen practice workspace

Interview experiences · Visa

Visa Senior+ Software Engineer Interview Experience — Online Assessment with Perfect Substring and Connected Groups

OAInterviewed 2026-08

Online Assessment First question: Perfect Substring Given a string s made up only of digits, and an integer k, we need to find the number of substrings that satisfy a specific condition: every distinct digit character that appears in the substring must appear exactly k times. Input: string s and integer k Output: the total count of substrings satisfying the condition Example: if s = "11020211" an…

Online Assessment

First question: Perfect Substring
Given a string s made up only of digits, and an integer k, we need to find the number of substrings that satisfy a specific condition: every distinct digit character that appears in the substring must appear exactly k times.

  1. Input: string s and integer k
  2. Output: the total count of substrings satisfying the condition
  3. Example: if s = "11020211" and k = 2, the substrings "11" ('1' appears 2 times) and "0202" ('0' and '2' each appear 2 times) both satisfy the condition

Second question: Connected Groups
Given an N x N matrix related representing a relationship network. If related[i][j] is '1', it means entity i and entity j are directly connected; if it's '0', they are not directly connected.
The connection relationship is transitive, meaning if A is connected to B, and B is connected to C, then A, B, and C belong to the same group.

  1. The task is to compute how many disjoint connected components (groups) exist in the entire network
  2. This is a classic graph connected-components problem, which can be solved using DFS, BFS, or Union-Find

Comments

Nothing here yet.

Join in on CSWork →