Amdocs Coding Question | Rotated String

Hello friends, I hope you all are doing great. In this post today we will learn to solve the  coding questions which is being asked by the Amdocs company recently. If you are preparing for selection in any company then this post will help you definitely.

Lets Start

Click here to get All Company Coding + Interview Questions and Programs All Coding Programs

Rotated String 

Given a string a , and flag (-m or m) , you are required to write a function that does the following: if flag=m : rotate the elements of the string a,m elements right. if flag=-m: rotate the elements of the string a,m elements left.

The function prototype is :

rotateString(String a, int flag):

a-the string to be rotated 

flag- if flag=m : rotate the elements of the string a,m elements right otherwise left.

The function should return rotated string.

Example :-

  • Input:
    • Easy
    • -1
  • Output:
    • asyE


Since the flag is negative so it will rotate left.

Code in Python

#Code in Python
class TestImpl:
    def rotateString(self,a,flag):
        if flag>0:
            return a[len(a)-flag]+a[0:len(a)-flag]
            return a[abs(flag):] + a[0:abs(flag)]

        #Drive code


Code in Java
import java.util.Scanner;

class RotateString {

    static String rotateString(String a, int flag) {
        if (flag > 0) {
            return a.substring(a.length() - flag) + a.substring(0, a.length() - flag);
        } else {
            return a.substring(Math.abs(flag)) + a.substring(0, Math.abs(flag));

    public static void main(String[] args) {
        System.out.println( rotateString("Easy", -1));

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 


Post a Comment


  1. Harrah's Lake Tahoe, Stateline - Mapyro
    The Harrah's Lake Tahoe is an iconic hotel 파주 출장안마 and casino situated in Stateline, Nevada, just north of Stateline. The hotel features a 충주 출장안마 casino, 광명 출장마사지 spa, and a Address: 1375 Stateline 충주 출장안마 Blvd S, Stateline, NV 89109Phone: +1 702 770 부천 출장안마 7000