Cognizant GenC Elevate Sample Coding Question 9

Question 9

In this article, we will discuss about Coding Question with their solution in C++ and java. In this question , we have to find the number of words that remain same after rotating the characters of the word left to right N times.

Question 9

Question 9

Vira writes an apology letter to anu. However, before Anu can read it, Vira’s enemy Rohan takes it and rotates the characters of each word left to right N times. Find the number of words that remain the same even after this shifting of letters.

Input Specification:

  • input1: String of words
  • input2: N, number of times rotation happens

Output Specification:

  • Your function should return the number of correct words.

Example 1:

input1: llohe ereth
input2: 2

Output : 2

Example 2:

input1: Sorry
input2: 2

Output : 0