Bloomberg LP Interview Question for Software Engineer / Developers






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

char *revcopy(char *s)
{
int i, len = strlen(s);
char *ret;

ret = malloc(len+1);
for (i = 0; i < len; i++)
ret[i] = s[len-i-1];

ret[i] = 0;
return ret;
}

- knakov April 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

cannot return a pointer like this,

dangling ref!!!

- ani August 27, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

How do u think it creates dangling reference? Since memory was allocated using malloc(), it is fine to record pointer in different variable and delete the previous pointer.

- sp101 September 04, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void ReverseWords (char str[])
{
	int start = 0, end = 0, length;
	length = strlen(str);
	while (end < length) {
		if (str[end] != ' ') { /* Skip non-word characters */
			start = end;
			while (end < length && str[end] != ' ') end++;
			end--;
			ReverseString(str, start, end);
		}
		end++; /* Advance to next token */
	}
return;
}

void ReverseString (char str[], int start, int end) 
{ 
        char temp; while (end > start) {
	/* Exchange characters */
	temp = str [start];
	str [start] = str [end] ;
	str [end] = temp;
	/* Move indices towards middle */ start++; end--;
} 
	return; 
}

- Java Coder November 26, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use recursion ......

void revstr(char*p)
{

static int k=0;
char ch;


if(*p=='\n')
return;

else
{
ch=p[0];
return revstr(p+1);
}

p[k++]=ch;

}

- Anonymous August 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using namespace std;

int main()
{
	const char * word="Hello How are you doing";
	int size=strlen(word);

	char * newWord =static_cast<char *>(malloc(size+1));
	int j=0;
	
	for (int i = size-1; i >=0; --i)
	{
		newWord[j]=word[i];
		j++;
	}
	

	int newWordsize=strlen(newWord);	
	cout << word << "\n" << newWord << endl;
	return 0;
}

- 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