Amazon Interview Question for Software Engineer in Tests


Country: United States
Interview Type: Phone Interview




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

public String convert(Integer value){
return value+"";
}

- Chaitanya Srikaolapu November 18, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

stack<int> getDigits(int b)
{
	stack<int> digits;
	int x, digit;
	int a = b;
	while (a > 10)
	{
		x = (a / 10);
		digit = a - (x * 10);
		digits.push(digit);
		a = x;
	}
	digits.push(a);
	return digits;
}

//int StringToNum(string s)
//{
//
//}


string NumToString(int a)
{
	string s;
	stack<int> digits = getDigits(a);
	int size = digits.size();
	for (int i = 0; i < size; i++)
	{
		int num = digits.top();
		s.push_back(num +48);
		digits.pop();
	}
	return s;
}

- Krishna Kumaran November 27, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>

using namespace std;

char int_to_char[10] = { '0','1', '2', '3', '4', '5', '6', '7', '8', '9' };

char* toString(int i){
if (i == 0){
char* c = new char[1];
*c = '0';
return c;
}
char* r;
int absolute = i;
if (i < 0){
absolute = -1 * absolute;
}
int len = 0;
while(absolute > 0){
len++;
absolute = absolute/10;
}

absolute = i;
if (i < 0){
absolute = -1 * absolute;
len++;
}

r = new char[len];

while(absolute > 0){
r[--len] = int_to_char[absolute % 10];
absolute = absolute/10;
}
if (i < 0){
r[--len] = '-';
}
return r;
}

int main()
{
cout << toString(-100);
// handle delete of allocations
return 0;
}

- Anonymous November 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>

using namespace std;

char int_to_char[10] = { '0','1', '2', '3', '4', '5', '6', '7', '8', '9' };

char* toString(int i){
    if (i == 0){
        char* c = new char[1];
        *c = '0';
        return c;
    }
    char* r;
    int absolute = i;
    if (i < 0){
        absolute = -1 * absolute;
    }
    int len = 0;
    while(absolute > 0){
        len++;
        absolute = absolute/10;
    }
    
    absolute = i;
    if (i < 0){
        absolute = -1 * absolute;
        len++;
    }
    
    r = new char[len];
    
    while(absolute > 0){
        r[--len] = int_to_char[absolute % 10];
        absolute = absolute/10;
    }
    if (i < 0){
        r[--len] = '-';
    }
    return r;
}

int main()
{
    cout << toString(0);
    // handle delete of allocations
    return 0;
}

- Object November 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Stack;

public class TestProgramming {
public static void main(String ar[]) {
int i=2345678;
Stack<Integer> stack = new Stack<Integer>();
while(i>0) {
int curr=i%10;
i=i/10;
stack.push(curr);
}
StringBuilder sbr=new StringBuilder();
while(!stack.isEmpty())
sbr.append(stack.pop());
String str=sbr.substring(0);
System.out.println(str);
}
}

- vitebonus December 03, 2019 | 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