Bloomberg LP Interview Question for Financial Software Developers






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

First you need to have a clear definition of what a "word" is. Essentially you can solve this task by storing all words in a container and then reversing the container. The more difficult more is to parse to string.

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

#include<iostream>
using namespace std;

int main()
{
int n;
char ch;
cout<<"enter no \n";
cin>>n;
for(;n;)
{
//cout<<n&1?'1':'0';
ch = (n&1)?'1':'0';
n = n>>1;
cout<<ch;
}
system("pause");
return 0;
}

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

sorry the above code is for unsigned bit pattern

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

use an empty string. Then use the method .length() on the given string. Then take characters from the end as in an array, and attach it to the empty string. THis way you'll reverse it

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

reverse the whole string, then reverse characters in each word

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

void reverse_word(char* begin, char*end)
{
//*end is a whitespace of '\0'
// Don't use any length pointer.
--end;
while(begin < end){
swap(*begin,*end);
begin++;end--;
}
}

void reverse_sentence(char* sentence)
{
char*begin= sentence, *end=sentence;
while(*end){
while(*end || *end != ' ') {
end++;
}
reverse_word(begin,end); // reverses each word.
if(*end) {begin = end+1;end = begin;}
}
reverse_word(sentence,end); // reverses the entire sentence
}

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

this is giving me a segmentation fault. !

- sk April 17, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

my bad !

- sk April 17, 2009 | Flag
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);
    /* Reverse entire string */
    reverseString(str, start, length - 1);

    while( end < length ){
       if( str[end] != ' ' ){ /* Skip non-word characters */

           /* Save position of beginning of word */
           start = end;

           /* Scan to next non-word character */
           while( end < length && str[end] != ' ' )
               end++;
            /* Back up to end of word */
            end--;

            /* Reverse word */
            reverseString( str, start, end );
        }
        end++; /* Advance to next token */
    }
}

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--;
    }
}

- Anonymous June 23, 2009 | 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