Bloomberg LP Interview Question for Financial Software Developers






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

#include <iostream>
using namespace std;

void str_reverse(char *str) {
	int sz = strlen(str);
	
	for (int i = 0; i < (sz/2); i++) {
		char tmp = str[i];
		str[i] = str[sz-i-1];
		str[sz-i-1] = tmp;
	}
}

int main() {
	char test[] = "abcdefgh";
	str_reverse(test);
	cout << test << endl;

	return 0;	
}

- jbong June 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

swap the characters.

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

swap the chars using + or xor operator w/o using any extra space.
e.g. in java.

public static char[] reverse(char[] in){
		for(int i = in.length-1, j=0; (i-j) > 0; j++, i--){
			in[j] = (char)((int) in[j] + (int) in[i]);
			in[i] = (char) ((int)in[j] - (int)in[i]);
			in[j] = (char) ((int)in[j] - (int)in[i]);
		}
		return in;
	}

- mast June 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can someone explain the problem .. am not gettin it

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

jbong's method is better for space complexity. We can improve speed by moving declaration of tmp out of for loop.
mast's - type casting from char to int will it not create temporary variables in memory?

- sachin.magdum July 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Common people lets not paste stupid problems here ..

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

Thats what Bloomberg is asking in interviews ....

- Hello September 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

while(indexStart < indexEnd)
{
swap(array[indexStart],array[indexEnd]);
indexStart++;
indexEnd--;
}

- Angelo September 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

while(indexStart < indexEnd)
{
swap(array[indexStart],array[indexEnd]);
indexStart++;
indexEnd--;
}

- Angelo September 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

while(indexStart < indexEnd)
	{
		swap(array[indexStart],array[indexEnd]);
		indexStart++;
		indexEnd--;
	}

- Angelo September 11, 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