dmelloleslie
BAN USER- 0of 0 votes
Answers1st Phone screen:
- dmelloleslie
Given a series A,B,C .......Z, AA, AB,AC,AD....AZ,BA,BB...BZ,CA....(Open excel sheet. The names of column represent the series). Given input as number 'n'. Output the 'n' th string of the series.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation
int increment(int nextinput)
{
static int digit=-1;
static int count=0;
static int isFirst =1;
if(nextinput ==10)
{
cout<<(digit+1)<<" ";
if(count)
{
while(count)
{
cout<<"0 ";
count--;
}
}
}
else if(nextinput!=9)
{
if(!isFirst)
{cout<<digit;}
digit = nextinput;
if(count)
while(count)
{
cout<<"9 ";
count--;
isFirst=1;
}
else isFirst=0;
cout<<endl;
}
else
{
isFirst=0;
count++;
}
}
#include <iostream>
#include <map>
#include <string>
#include <conio.h>
using namespace std;
int main(int argc, char *argv)
{
map<char, int>input;
string s;
cout<<"Enter the String:";
cin>>s;
for(int i=0; i< s.length(); i++)
input[s[i]]++;
map<char, int>::const_iterator iter;
for(iter=input.begin(); iter!=input.end();iter++)
if(iter->second == 1)
{cout<<iter->first; break;}
getch();
}
more explanation pls
- dmelloleslie April 06, 2010Yes. A pointer of type base class can point to derived class object. But the opposite is not true. Here's how:
base *bp;
derived d;
bp = &d; // base pointer points to derived object
bp->set_i(10); // access derived object using base pointer
Question is now corrected.
- dmelloleslie March 29, 2010temp=temp1=n;
while(temp>0) // Find no of characters string will contain
{
no_of_char++;
temp=temp-pow(26,no_of_char);
}
str = (char *)malloc(no_of_char+1);// Dynanically Allocate the buffer
while(temp1>0)
{
temp= temp1 %26; // To find no with respect to alphabet
if(temp!=0)
str[next_char_index++]=temp+65-1;
else
{ // When modulas = 0 we know it is Z(since 26)
str[next_char_index++]='Z';
temp1--;
}
temp1= temp1/(26); // divide by 26 for next pass
}
str[next_char_index]='\0'; // Terminate string with NULL character
strrev(str); // since the characters are stored in reverse manner
int findfirstgreaterthanequal(int *a, int start, int end , int &index, int val)
- dmelloleslie July 16, 2013{
if (start > end ) return 0;
int mid = (start + end )/2;
if(a[mid] >= val && mid < index )
{
index = mid;
}
findfirstgreaterthanequal(a, start, mid-1, index, val);
findfirstgreaterthanequal(a, mid+1, end, index, val);
return a[index];
}