Amazon Interview Question for Software Engineer / Developers






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

Using a stack integer of length n can be added here. Same can be done for subtraction.

Stack st1 = new Stack();
Stack st2 = new Stack();
//Adding number 129 + 138 split it and push to stack.
st1.push(1);
st1.push(2);
st1.push(9);

st2.push(1);
st2.push(3);
st2.push(8);
StringBuffer res= new StringBuffer();
int carry = 0;
for(int i =0 ; i < 3;i++){
    int a = (int) st1.pop();
    int b = (int) st2.pop();
    int temp = a + b + carry;
    if(temp > 9){
        carry = 1;
        temp = temp - 10;
    }
    else{
        carry = 0;
    }
    res = res.append(temp);
}
System.out.println(res.reverse());

Courtesy - https://sites.google.com/site/arjunwebworld/Home/programming/programmatic-questions

- rahul.s July 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use linkedlist for that

- Anonymous March 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes we can use linked list to implement this :)

- geeks July 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Vector or ArrayList. Easy to traverse

- const volatile March 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

we can use a int array, check the BigInteger implementation in java.

- monish March 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How would you declare an array of unlimited size?

- Arijit April 03, 2011 | Flag


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