Zig-Zag Conversion Problem Statement
You are given a string S
and an integer ROW
. Your task is to convert the string into a zig-zag pattern on a given number of rows. After the conversion, output the string row-wise.
Refer to the example below for better understanding of how the zig-zag pattern should be arranged.
Example:
Input:
S = "beaninjacoder", ROW = 4
Output:
"bjrenaeaicdno"
Explanation:
The zig-zag pattern is: b j r e n a e a i c d n o Therefore, outputs row-wise result in the string "bjrenaeaicdno".
Constraints:
1 ≤ T ≤ 10
1 ≤ |S| ≤ 10000
1 ≤ ROW ≤ 10000
S
only contains lowercase English alphabets- Time limit: 1 sec
Be the first one to answer
Add answer anonymously...
Top Freshworks Lead Software Engineer interview questions & answers
Popular interview questions of Lead Software Engineer
Top HR questions asked in Freshworks Lead Software Engineer
>
Freshworks Lead Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app