Divide String Problem Statement
You are given a string WORD
consisting of lowercase alphabets. Your task is to divide WORD
into N
strings of equal length.
Input:
The first line contains an integer 'T' representing the number of test cases. Each test case consists of a string WORD
and an integer N
.
Output:
For each test case, output all strings formed by dividing WORD
into N
equal parts. If it is not possible, return an empty string array/list. Print the output for each test case on a new line.
Example:
Input:
WORD = "abcdefgh", N = 2
Output:
["abcd", "efgh"]
Explanation:
The string WORD
is divided into two parts of equal length: "abcd"
and "efgh"
.
Constraints:
1 <= T <= 100
WORD
consists of lowercase English alphabets1 <= |WORD| <= 2000
1 <= N <= |WORD|
Note: You do not need to print anything; just implement the function.
Be the first one to answer
Add answer anonymously...
Top Springworks Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Springworks Software Developer Intern
>
Springworks Software Developer Intern 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