Research In Motion Interview Question for Software Engineer in Tests






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

//Problem:
//================
//I/P: CareerCup
//O/P: p_Cr__r_C

//Tasks:
//1. Reveres the string.
//2. Replace every vowel with space.


//Example:
//================

//I/P: CareerCup
//O/P: p_Cr__r_C


//ALGO:
//================
//1. reverse the string by using a temp and run till n/2
//check even or odd
// while swap check for all vowels.



//TEST CASES:
//================

//Functional tests:

//1. if all are vowels
//2. none is vowels
//3. all are spaces
//4. null string
//5. even odd string
//6. Limit Testing (BVA)
//7. integers in the string
//8. escape characters
//9. special characters

//N.Functional

//Performance:
//1. Send the same string and test for execution run time
//Memory
//2. keep on executing with same result and check for memory leaks
//stress
//4. run multiple calls of the same method
//security
//5. send string with escape characters and \0 , null string terminating sequence
//load:
//6. test with very long string
//localization\globalization
//7. test with mix if char and integers
//8. test with kanji[japenese] char
//9. test with unicode and ASCII and special char
//10. test with mix of unicode and japenese characters.



//TEST HARNESS:
//================

using System;
namespace problem
{
public class answer
{
static void Main()
{
string S = "CareerCup";
Console.WriteLine(replacereversestring(S));
System.Console.ReadLine();
}


//CODE:
//================

public static string replacereversestring(string s)
{
int strlen = s.Length;
char[] strarray = s.ToCharArray();
string Result = "";

if (strlen % 2 != 0)
{
int j = strlen-1;
for (int i = 0; j-i>=0; i++, j--)
{
if (strarray[i] == Convert.ToChar("a") || strarray[i] == Convert.ToChar("i") || strarray[i] == Convert.ToChar("o") || strarray[i] == Convert.ToChar("u") || strarray[i] == Convert.ToChar("e"))
{
strarray[i] = Convert.ToChar(" ");
}
if (strarray[j] == Convert.ToChar("a") || strarray[j] == Convert.ToChar("i") || strarray[j] == Convert.ToChar("o") || strarray[j] == Convert.ToChar("u") || strarray[i] == Convert.ToChar("e"))
{
strarray[j] = Convert.ToChar(" ");
}

answer.swap(i, j, strarray);

}
return Result = new string(strarray);
}

else
{
int j = strlen-1;
for (int i = 0; j - i >= 1; i++, j--)
{
if (strarray[i] == Convert.ToChar("a") || strarray[i] == Convert.ToChar("i") || strarray[i] == Convert.ToChar("o") || strarray[i] == Convert.ToChar("u") || strarray[i] == Convert.ToChar("e"))
{
strarray[i] = Convert.ToChar(" ");
}
if (strarray[j] == Convert.ToChar("a") || strarray[j] == Convert.ToChar("i") || strarray[j] == Convert.ToChar("o") || strarray[j] == Convert.ToChar("u") || strarray[i] == Convert.ToChar("e"))
{
strarray[j] = Convert.ToChar(" ");
}

answer.swap(i, j, strarray);

}
return Result = new string(strarray);
}

}
public static void swap(int i, int j, Char[] strarray)
{
char temp= strarray[i];
strarray[i]=strarray[j];
strarray[j]=temp;
}

}
}





//ORDER:
//================
//O(N)

- Tarun Phaugat March 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

plzzzzzzzzzzzz for holy heaven's sake ... plz post just the algorithm (preferably).. or just the code..

- Anonymous March 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I remember in 'Programming Pearls' John Bentely told a story where he assigned the class to write a simple program and most students wrote in his opinion average code and he gave like C and 2 guys who worked in software industry wrote a 5 page code with all the software engineering principles and he gave those guys failing grade.

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

Truely Funny Yaar !!! :P

- Harish March 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think he has given very comprehensive answer - don't make fun of him.

- Anonymous December 02, 2010 | 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