Palindromic grid
Practice
4 (7 votes)
Basic programming
Basics of implementation
Easy
Implementation
String manipulation
Problem
74% Success 2823 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a 2-d grid of N rows and M columns containing lower case alphabets only. You need to check whether it is possible to rearrange the complete grid so that each row and column becomes palindromic.
Input :
- The first line of input contains T, the number of test cases.
- The first line of each test case contains two space-separated integers N and M, denoting the number of rows and columns.
- Each of the following N lines contains a string of length M.
Output :
- Output YES if it is possible to rearrange the grid to make all the rows and columns palindromic. else output NO.
Constraints :
- \(1 \le T \le 10 \)
- \(1 \le N , M \le 10^{3}\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
25 votes
Tags:
Basic ProgrammingC++
Points:20
31 votes
Tags:
Ad-HocBrute-force searchEasyImplementation
Points:20
27 votes
Tags:
Basic Programming
Editorial