2daysbeforeinterview
Home1Companies2Problems3Experiences4Compensation5Assistant

Spaces

Saved work

Your prep

Notes6Bookmarks7Submissions

Community

Leaderboard8Send feedback
Contribute9
2daysbeforeinterview
2daysbeforeinterview

Straight from the interview room.

Browse

  • Companies
  • Problems
  • Experiences
  • Compensation
  • Leaderboard
  • Pricing

Contribute

  • Add a question
  • Share an experience
  • Report compensation
  • Committed Contributor
  • Send feedback

About

  • About 2daysbeforeinterview
  • Contact
  • Privacy
  • Terms
  • Refunds
  • Delivery

© 2026 2daysbeforeinterview

  • Instagram(opens in a new tab)
  • YouTube(opens in a new tab)
  • X (Twitter)(opens in a new tab)
  • help@2daysbeforeinterview.com
HomeCompaniesProblems
Keep holding ⌥Alt and press a number · ? for every shortcut
Home1Companies2Problems3Experiences4Compensation5Assistant

Spaces

Saved work

Your prep

Notes6Bookmarks7Submissions

Community

Leaderboard8Send feedback
Back to questions
DSA
1 reportlast asked …
Licious

Check Palindromic Array

  • Arrays

Given an array of strings arr, the array is a palindromic array if every element is equal to its corresponding pair: the first element equals the last, the second equals the second-to-last, and so on.

If the array is not palindromic, you can try to convert it into a palindromic array by performing the following operations any number of times:

  1. Take a prefix from an element's right neighbour and add it to the element as a suffix.
  2. Take a suffix from an element's left neighbour and add it to the element as a prefix.

A move can take any number of characters, but every element must keep at least one character, so the number of elements never changes. Return true if arr is already palindromic or can be converted into a palindromic array with these operations, otherwise false.

Example 1

Input:  arr = ["ab","a","aa","b"]
Output: true

Shift the 3rd element's suffix "a" to the 4th element's prefix: ["ab","a","a","ab"].

Example 2

Input:  arr = ["aa","ba","a","baaa","b"]
Output: true

Shift the 2nd element's prefix "b" to the 1st element's suffix, the 4th element's suffix "aa" to the 5th element's prefix, and the 4th element's prefix "b" to the 3rd element's suffix: ["aab","a","ab","a","aab"].

Example 3

Input:  arr = ["ab","ba"]
Output: false

The characters together read "abba", a palindrome, but a palindromic array of two elements needs both elements equal, and no shift makes "ab" and "ba" equal.

Constraints

  • 1 <= arr.length <= 1000
  • 1 <= arr[i].length
  • The total number of characters across all elements is at most 2000.
  • arr[i] consists of lowercase English letters.

Hints

0/3

Domains

Backend
asked Jul 2023Report
Discussion
Related questions
Asked atLicious
My notes
Practice
EditorialLocked
Community solutions
Learning resources(3)
Licious
Licious
  • Practise the Licious loop›