Epic Systems Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
6
of 6 vote

int shift = 2;
char word[] = {'a','B','c','X',0}, *str = word;
while(*str) {
  if( *str >= 'a' && *str <= 'z' ) { // lowercase
    *str = ((*str+shift-'a')%26)+'a';
  }
  else if ( *str >= 'A' && *str <= 'Z' ) { // uppercase
    *str = ((*str+shift-'A')%26)+'A';
  }
  ++str;  
}

- coder February 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

awesome!

- Anonymous April 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

public static String strConverter(String str)
{
    StringBuilder newStr = new StringBuilder();
    int shift = 2; // shift value



for(int i=0;i< str.length();i++)
{
char ch = str.charAt(i);
// perform Caesar shift
if((ch >= 'a') && (ch <= 'z'))
ch = (char)('a'+(ch-'a'+shift)%26);
else if((ch >= 'A') && (ch <= 'Z'))
ch = (char)('A'+(ch-'A'+shift)%26);
// build the string with the shifted char
newStr.append(ch);
}
return newStr.toString();
}

- pondy April 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

working program. thanks

- Koti November 20, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. 97 + ((ch[0]-97) + 2)%26
2. 97 + ((ch[1]-97) + 2)%26
3. 97 + ((ch[2]-97) + 2)%26
4. 65 + ((ch[3]-65) + 2)%26

- YetAnotherCoder October 26, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

string GreetingText="abcD";
//GreetingText+="We do hope you enjoy this book as much as we enjoyed writing it.";

for(int i =(int)'z';i>=(int)'a';i--)
{
char old1=(char)i;
char New1=(char)(i+2);
GreetingText=GreetingText.Replace(old1,New1 );
}

for(int i= (int)'Z';i>=(int)'A';i--)
{
char old1=(char)i;
char new1=(char)(i+2);
GreetingText=GreetingText.Replace(old1,new1);

}
Console.WriteLine("Encoded:\n"+GreetingText) ;
Console.Read();

- Intelligent_soul February 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a simpler solution might be to use unix tr command

- anon March 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public String strConverter(String str)
{
    StringBuilder newStr = new StringBuilder();
    int shift = 2; // shift value

    for(int i=0;i< str.length();i++)
    {
       char ch = str.charAt(i);
       // perform Caesar shift
       ch = (char)(‘a’+(ch-‘a’+shift)%26);
       // build the string with the shifted char
       newStr.append(ch);
    }
    return newStr.toString();
}

- TonyYang March 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we need to even take care of the cycling at the end. i.e if the letter is Y, then Y+2 = A , y+2 = a , Z+2 = B , z+2 = b.

This code works in C++

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
char shift_string[10]="rlzY";

for(int i=0;shift_string[i]!='\0';i++)
{


if(shift_string[i]=='Y')
shift_string[i]='A';

else if(shift_string[i]=='y')
shift_string[i]='a';


else if(shift_string[i]=='Z')
shift_string[i]='B';

else if(shift_string[i]=='z')
shift_string[i]='b';


else
shift_string[i]=(char)shift_string[i]+2;



}


cout<<"\n Shifted string is " <<shift_string;

cout<<"\n";
return(0);

}

- Swetha April 10, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static String strConverter(String str)
{
    StringBuilder newStr = new StringBuilder();
    int shift = 2; // shift value



for(int i=0;i< str.length();i++)
{
char ch = str.charAt(i);
// perform Caesar shift
if((ch >= 'a') && (ch <= 'z'))
ch = (char)('a'+(ch-'a'+shift)%26);
else if((ch >= 'A') && (ch <= 'Z'))
ch = (char)('A'+(ch-'A'+shift)%26);
// build the string with the shifted char
newStr.append(ch);
}
return newStr.toString();
}

- pondy April 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

void convertString(string inputString, int shiftpos)
{
int start = 0;
int end = 0;
char referencechar;
string newstr = "";
int len = inputString.length();
for(int i =0;i<len;i++)
{
start = i;
end = start+1;
char ch = (char)inputString[i];
if(ch>='a'&&ch<='z')
{
referencechar = 'a';
}
else if(ch>='A'&&ch<='Z')
{
referencechar = 'A';
}
ch = (char)(referencechar+(ch-referencechar+shiftpos)%26);
cout<<"[newstring:"<<ch<<"]\n";
}
}

- wanna April 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void convertString(string inputString, int shiftpos)
{
int start = 0;
int end = 0;
char referencechar;
string newstr = "";
int len = inputString.length();
for(int i =0;i<len;i++)
{
start = i;
end = start+1;
char ch = (char)inputString[i];
if(ch>='a'&&ch<='z')
{
referencechar = 'a';
}
else if(ch>='A'&&ch<='Z')
{
referencechar = 'A';
}
ch = (char)(referencechar+(ch-referencechar+shiftpos)%26);
cout<<"[newstring:"<<ch<<"]\n";
}
}

- wanna April 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

string convert(string inp)
{
       int i;
       for(i=0;i<inp.size();i++)
       {
        if(inp[i]>='a' && inp[i]<='z')
       inp[i]='a'+(inp[i]-'a'+2)%26;
       
       else
       inp[i]='A'+(inp[i]-'A'+2)%26; 
       
       } 
       
       return inp;
       
       }

- Anonymous July 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char c[10];
int b[10];
int i;
printf("Enter the String:");scanf("%s",&c);
int l=strlen(c);
printf("String Length: %d\n", l);
printf("Input String:");
for(i=0;i<l;i++)
{
printf("%c",c[i]);
}
printf("\n Shifted String :");
for(i=0;i<l;i++)
{
b[i]=c[i];
}
for(i=0;i<l;i++)
{
b[i]=b[i]+2;
c[i]=b[i];
printf("%c",c[i]);
}

// printf("%d\n",b[i]);

getch();
}

- Anonymous September 23, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This does not work for ZzYy.. the cycling alphabets

- Priya September 30, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

scanf("%s",&c); ???? &c????

- Anonymous October 12, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
main()
{
char p;
printf("Enter a string\t");
scanf("%s",&p);;
convertString(&p);
}
convertString(char *s)
{
int j = 0,i;

while(s[j] != '\0')
{
if(s[j] == 'y')
{
s[j] = 'a';
j++;
}
else if(s[j] == 'z')
{
s[j] = 'b';
j++;
}
else if(s[j] == 'Y')
{
s[j] = 'A';
j++;
}
else if(s[j] == 'Z')
{
s[j] = 'B';
j++;
}
else
{
i = s[j];
i = i + 2;
//printf("%d ---->>>>> %c\n",i,i);
s[j] = i;
j++;
}

}
printf("%s\n",s);
}

- shortSweet November 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
ConvertString(input);



Console.ReadLine();

}

static void ConvertString(string stringinput)
{
int shift = 2;
string temp = "";
for (int i = 0; i < stringinput.Length; i++)
{
temp += Convert.ToChar((stringinput[i] + shift-'a')%26+'a');

}
Console.WriteLine(temp);



}
}
}

- C# December 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package b;

public class CovertStringToAnother {
	public static void main(String[] args){
		String in = "plxy";
		String op = "";
		
		for(int i = 0; i < in.length(); i++){
			char c = in.charAt(i);
			if(c == 'y' || c=='z' || c=='Y' || c=='Z'){
				switch(c){
					case 'y' : op += 'a'; 
							   break;
					case 'z' : op += 'b';
							   break;
					case 'Y' : op += 'a'; 
					   break;
					case 'Z' : op += 'b';
					   break;
				}
			}else{
				c += 2;
				op += c;
			}
		}
		
		System.out.println(op);
	}
}

- Dr. Java April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package b;

public class CovertStringToAnother {
	public static void main(String[] args){
		String in = "plxy";
		String op = "";
		
		for(int i = 0; i < in.length(); i++){
			char c = in.charAt(i);
			if(c == 'y' || c=='z' || c=='Y' || c=='Z'){
				switch(c){
					case 'y' : op += 'a'; 
							   break;
					case 'z' : op += 'b';
							   break;
					case 'Y' : op += 'a'; 
					   break;
					case 'Z' : op += 'b';
					   break;
				}
			}else{
				c += 2;
				op += c;
			}
		}
		
		System.out.println(op);
	}
}

- Dr. Java April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void convertString(char *input)
{
int i=0;

while(input[i]!='\0')
{
if(input[i]<=122 && input[i]>=92)
{
input[i]=input[i]+2>122 ? input[i]-24: input[i]+2;
}
else if(input[i]<=90 && input[i]>=65)
{
input[i]=input[i]+2>90 ? input[i]-24: input[i]+2;
}
else
{
printf("Please enter the letter between 'A'-'Z' or 'a'-'z'\n");
}
i++;
}
}

- damon August 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

string s("bziY");
int len=s.size();
for (int i=0; i<len; i++) {
if (s[i]<='Z'&&s[i]>='A') {
s[i]=(s[i]-'A'+2)%26+'A';
}
else if (s[i]>='a'&&s[i]<='z') {
s[i]=(s[i]-'a'+2)%26+'a';
}
}

- Anonymous September 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<string.h>
int main()
{
char str[]="loLaAyY";
int len=strlen(str);
auto int i;
for(i;i<len;i++)
{
if(str[i]>='a' && str[i]<='z')
{
if(str[i]+2>='z')
str[i]=((str[i]+2)% 'z')+'a'-1;
else
str[i]=(str[i]+2);

}
else if(str[i]>='A' && str[i]<='Z')
{
if(str[i]+2>='Z')
str[i]=((str[i]+2)% 'Z')+'A'-1;
else
str[i]=(str[i]+2);
}
}
printf("%s\n",str);
return 0;
}

- mayawati( hanthi wali bahanji ) :P October 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<string.h>
int main()
{
char str[]="loLaAyY";
int len=strlen(str);
auto int i;
for(i;i<len;i++)
{
if(str[i]>='a' && str[i]<='z')
{
if(str[i]+2>='z')
str[i]=((str[i]+2)% 'z')+'a'-1;
else
str[i]=(str[i]+2);

}
else if(str[i]>='A' && str[i]<='Z')
{
if(str[i]+2>='Z')
str[i]=((str[i]+2)% 'Z')+'A'-1;
else
str[i]=(str[i]+2);
}
}
printf("%s\n",str);
return 0;
}

- mayawati( hanthi wali bahanji ) October 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<string.h>
int main()
{
char str[]="loLaAyY";
int len=strlen(str);
auto int i;
for(i;i<len;i++)
{
if(str[i]>='a' && str[i]<='z')
{
if(str[i]+2>='z')
str[i]=((str[i]+2)% 'z')+'a'-1;
else
str[i]=(str[i]+2);

}
else if(str[i]>='A' && str[i]<='Z')
{
if(str[i]+2>='Z')
str[i]=((str[i]+2)% 'Z')+'A'-1;
else
str[i]=(str[i]+2);
}
}
printf("%s\n",str);
return 0;
}

- mayawati_hanthi_wali_bahanji October 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<string.h>
int main()
{
char str[]="loLaAyY";
int len=strlen(str);
auto int i;
for(i;i<len;i++)
{
if(str[i]>='a' && str[i]<='z')
{
if(str[i]+2>='z')
str[i]=((str[i]+2)% 'z')+'a'-1;
else
str[i]=(str[i]+2);

}
else if(str[i]>='A' && str[i]<='Z')
{
if(str[i]+2>='Z')
str[i]=((str[i]+2)% 'Z')+'A'-1;
else
str[i]=(str[i]+2);
}
}
printf("%s\n",str);
return 0;
}

- mayawati_hanthi_wali_bahanji October 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>

int main()
{
char str[]="plxY";

for(int i=0;i<strlen(str);i++)
{
if(str[i]>=65&&str[i]<=97)
{
str[i]+=2;
if(str[i]>=65+26)
str[i]-=26;
}
else
{
str[i]+=2;
if(str[i]>=97+26)
str[i]-=26;
}

}

printf(str);
return 0;
}

- Anonymous July 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
char str[100];
cin>>str;
for(int l=0;str[l]!='\0';l++)
{ if(str[l]<=96)
cout<<char(((int(str[l])-(69)+2)%26)+69);
else if(str[l]>97)
cout<<char(((int(str[l])-(97)+2)%26)+97);
}
}

- PJ February 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
	char str[100];
	cin>>str;
	for(int l=0;str[l]!='\0';l++)
	{	if(str[l]<=96)
			cout<<char(((int(str[l])-(69)+2)%26)+69);
		else if(str[l]>97)
			cout<<char(((int(str[l])-(97)+2)%26)+97);
	}
}

- PJ February 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
main()
{ int i,j=2;
char str[30],test[30];
char t;
printf("Enter the alphabetical code \n");
scanf("%s",str);
i=0;
while(str[i]!='\0')
{ str[i]=str[i]+2;
i++;
}
printf("The output string is %s\n",str);
}

- @123 August 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is the exact working code

#include<stdio.h>
main()
{ int i,j=2;
char str[30],test[30];
char t;
printf("Enter the alphabetical code \n");
scanf("%s",str);
i=0;
while(str[i]!='\0')
{ str[i]=str[i]+2;
if(str[i]>90 && str[i]<97)
str[i]=((str[i]-'A')%26) + 'A';
if(str[i]>122)
str[i]=((str[i]-'a')%26) + 'a';

i++;
}
printf("The output string is %s\n",str);
}

- @123 August 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Program
    {
        static void Main(string[] args)
        {
            String result = strConvert("abcD");
            Console.WriteLine(result);
            Console.Read();
        }

        public static String strConvert(String str)
        {
            StringBuilder newStr = new StringBuilder();

            int shift = 2; //shift value

            for (int i = 0; i < str.Length; i++)
            {
                char ch = str[i];

                if ((ch >= 'a') && (ch <= 'z'))
                {
                    ch = (char)('a' + (ch - 'a' + shift) % 26);
                }

                else if ((ch >= 'A') && (ch <= 'Z'))
                {
                    ch = (char)('A' + (ch - 'A' + shift) % 26);
                }

                newStr.Append(ch);

            }
          
            return newStr.ToString();

        }

        
    }

- Teva February 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Scanner;

public class convertString {

	public static void convert(String str) {

		char[] ch = str.toCharArray();
		for (int i = 0; i < ch.length; i++) {
			if (ch[i] >= 'a' && ch[i] <= 'z')
				ch[i] = (char) ('a' + (ch[i] + 2 - 'a') % 26);
			else if (ch[i] >= 'A' && ch[i] <= 'Z')
				ch[i] = (char) ('A' + (ch[i] + 2 - 'A') % 26);

		}
		for (char c : ch)
			System.out.print(c);
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter String");
		String s = sc.next();
		convert(s);
	}
}

- sanjeev kaneria March 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Solve {
public static void main(String[] args) throws Exception {
Deal_With_It("plxY");
}
public static String Deal_With_It(String str){
int number[]=new int[str.length()];
if(str.length()==0)
return "";
if(str.length()==1)
return str.toUpperCase();
for (int i = 0; i < str.length(); i++) {
number[i]=(int)str.charAt(i);
}
if(number[number.length-1]>=89)
number[number.length-1]=64+(90-number[number.length-1]);
else
number[number.length-1]+=2;
String result="";
for (int i = 0; i < number.length-1; i++) {
result+=Character.toString((char)(number[i]+2));
}
result+=Character.toString((char)number[number.length-1]);
System.err.println(result);
return "";
}
}

- TerrorGeek October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is a working code in C++.

#include <cstdio>
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    char str[100];
    int len, i, temp;
    cin>>str;
    len=strlen(str);
    for (i=0; i<len; i++)
    {
        str[i]+=2;
        if (str[i]>=97 && str[i]>122)
        {
            temp=(int)str[i];
            temp-=122;
            temp+=96;
            str[i]=(char)temp;
        }
        else if(str[i]>90 && str[i]<97)
        {
            temp=(int)str[i];
            temp-=90;
            temp+=64;
            str[i]=(char)temp;
        }
    }
    for (i=0; i<len; i++)
    {
        cout<<str[i];
    }
    return 0;
}

- Meraj Ahmed November 12, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char convertUtil(char c, int d)
{
if(c+2 > d)
return (c-24);

return c+2;
}

void convert(char *str)
{
if(str == NULL)
return;

if(strlen(str) <=0)
return;

int i=0;
while(str[i+1] != '\0') {
str[i]=convertUtil(str[i], 122);
i++;
}
str[i]=convertUtil(str[i],90);
}

- Anonymous February 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static String convertString(String inp, int shift) {
StringBuilder sb = new StringBuilder();
for (int i=0; i<inp.length(); i++) {
if (inp.charAt(i) <= 'Z' && inp.charAt(i) >= 'A') {
int x = (int) inp.charAt(i);
char ch = (char) ((((x%64)+shift)%26)+64);
sb.append(ch);
} else if (inp.charAt(i) <= 'z' && inp.charAt(i) >= 'a') {
int x = (int) inp.charAt(i);
char ch = (char) ((((x%96)+shift)%26)+96);
sb.append(ch);
}
}
return sb.toString();
}

- assassin November 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public String shift(String word)
	{	
		StringBuilder result = new StringBuilder();
		for(int i=0;i<word.length();i++)
		{	
			char start = '\0';
			char cur = word.charAt(i);
			if(cur>='a' && cur<='z')
				start = 'a';
			else if(cur>='A' && cur<='Z')
				start = 'A';
			char change = (char) (((char) ((cur-start)+2)%26) + start);
			
			result.append(change);
		}
		
		return result.toString();
	}

- Devesh November 25, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More