Company: visa associate swe Off campus_24march

Difficulty: medium

Problem Statement

A palindrome reads the same forwards and backwards, e.g.. "mom", "a", or "radar". You are given an array of n strings consisting of lowercase English letters. In one operation, you can swap any two letters from any two distinct strings in the array. Determine the maximum number of palindromic strings that can be obtained by performing any number of these operations. In other words, choose 4 integers, x, y, i, j such that 1 ≤ x, y ≤ n , 1 ≤ i ≤ length( arr[x] ), 1 ≤ j ≤ length( arr[y] ) and swap arr[x][i] and arr[y][j] using 1-based indexing. Example n = 4 arr = ["pass", "sas", "asps", "df"] An optimal solution produces 3 palindromes: Select x = 1, y = 3, i = 3, j = 1, swap ( arr[1][3], arr[3][1] ) Result: arr = ["paas", "sas", "ssps", "df"] Select x = 1, y = 3, i = 4, j = 3, swap ( arr[1][4], arr[3][3] ) Result: arr = ["paap", "sas", "ssss", "df"] Now we have 3 palindromic strings: "paap", "sas", and "ssss". Therefore, return 3. Function Description Complete the funct

More visa associate swe Off campus_24march OA questionsInterview experiences