Question: A palindrome is a word, which reads the same backward as forward. Some examples of palindromes are: kayak, radar, mom. Write a function: Class Solution

A palindrome is a word, which reads the same backward as forward. Some examples of palindromes are: "kayak", "radar", "mom".
Write a function:
Class Solution { public String solution(int N, int K); }
that, given two integers N and K, returns a palindrome of length N which consists of K distinct lower-case letters (a-z).
Examples:
Given N=5,K=2, your function may return "abbba". There are many other possibilities; for example, it could also return "zdzdz". On the other hand, "aaaaa" is an incorrect answer as it contains only one distinct letter.
Given N=8,K=3, your function may return "ppscespp".
Given N=3,K=2, your function may return "opo".
Assume that:
N is an integer within the range [1..200];
K is an integer within the range [1..26);
Creation of the required palindrome is always possible.
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Copyight 2009-2021 by Codilly Umited. All Rlghts Reserved. Unauthorized copylng. publleation or disclosure prohibited.
 A palindrome is a word, which reads the same backward as

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!