## Bloomberg LP Interview Question for Financial Software Developers

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

``````void encrypt(char str[])
{
char h=find(str);
cout<<"highst occuring character is "<<h<<"\n";
int dif='e'-h;

for(int i=0;i<strlen(str);i++)
{
int d=str[i]-97+dif;
if(d<=0)
str[i]=(d+26)%26+97;
if(d>0)
str[i]=d%26+97;
cout<<d;
}
}

char find(char str[])
{
int a[26]={0};
for(int i=0;i<strlen(str);i++)
a[str[i]-97]++;
int max=a[0];
int maxi=0;
for(int i=1;i<26;i++)
if(max<a[i])
{
max=a[i];
maxi=i;
}
return maxi+97;
}``````

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

``````void cipher(char* str)
{
unsigned int table[26] = {0};
const int len = strlen(str);
const unsigned char a = char('a');
const unsigned char e = char('e');

for (int i = 0; i < len; i++)
{
int val = str[i] - a;
table[val] += 1;
}

const ptrdiff_t off = max_element(table, table+26) - table ;
const size_t pos = e - a;
int distance = 0;
if ( off == pos)
;
else if ( off < pos)
distance = pos - off;
else
distance = pos - off + 26;

for (int i = 0; i < len; ++i)
{
str[i] = (((str[i] - a) + distance ) % 26) + a;
}
}``````

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

``````#include <stdio.h>

int main()
{
char str[] = "bloomberg";
int arr[26];

char *start = str;
char temp;
int i, max = 0;
int difffrome;
char tempChar;

while(*start)
{
temp = *start++;
arr[temp-'a']++;
}

//max char
for(i=1; i<26; i++)
{
if(arr[i]>arr[max])
max = i;
}

difffrome = 'e'-('a'+max);

start = str;
while(*start)
{
tempChar = *start+difffrome;
if(tempChar > 'z')
{
int diff = tempChar - 'z';
*start++ = 'a' + diff;
}
else if(tempChar < 'a')
{
int diff = 'a' - tempChar;
*start++ = 'z' - diff;
}
else
*start++ = tempChar;
}
}``````

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

``````void cipher( char *str )
{
char *start = str ;
int charArr[26] = {0} ;
int val ;
int i, maxIndex, max ;
int shiftDis ;

// Find the highest occruing char
while( *start )
{
val = *start - 'a' ; printf( " val is %d\n", val) ;
charArr[val] += 1 ;
*start++ ;
}

max = 0;
maxIndex = 0 ;
for( i = 0 ; i<26; i++ )
{
if ( charArr[i] > max )
{
max = charArr[i] ;
maxIndex = i ;
}
}

//Calculate the offset
shiftDis = 'e' - ( 'a' + maxIndex ) ;

start = str ;
while( *start )
{
val = *start - 'a' + shiftDis ;
if ( val >=0 ) *start = 'a' + val % 26 ;
else *start = 'a' + val + 26 ;
*start++ ;
}
}``````

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

#include<stdio.h>

int main(){

char* str = "bloomberg";
int i;
char maxChar;
int freq[26];
for(i=0; str[i] != '\0'; i++){
freq[str[i] - 'a']++;
}

int max = 0;
for(i=0; i<26; i++){
if(freq[i] > max) {
max = freq[i];
maxChar = 'a' + freq[i];
}
}

for(i=0; str[i] != '\0'; i++)
{
printf("%c", ((str[i] - maxChar + 'e' - 1) % 'z'));
}
return 0;
}

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.

### 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.