Amazon WoW Coding Questions and Answers 2023 (FAQ): Syllabus, Pattern, MCQ, Expected Q/A, & More


Amazon WOE MCQ Questions and Answers

Which of the following system programs joins individually compiled modules of a program to form an executable module?

a)Assembler
b)Linking loader
c)Cross compiler
d)Load and go

Ans: B

Which of these is an expression for runtime in T(n) for the following recurrence: T(n)=4T (n/ 2) + n²

a)O(n²)
b)O(nlogn)
c)O(n²logn)
d)O(nIog²n)

Ans: C

In Networking, which of the following defines the purpose of Ping?

a) It measures the round-trip time.
b) It reports packet loss.
c) It reports latency.
d) All of these

Ans: B

How many nodes does a complete binary tree with N leaves contain?

a)2N
b) N
c) 2N-1
d) N-1
e) 2(N-1)

Ans: C

What is the postfix expression for the following prefix expression:
*+pq-rs

a)pq + rs-*
b)pqrs +-*
c)pq + rs *-
d)pq+-rs*

Ans: A

Which of the following is an in-order traversal of a tree whose postorder traversal is 10, 9, 23, 22, 27, 25, 15, 50, 95, 60,40, 29?

a)9,10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
b)9,10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
c)29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
d)95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

Ans: A

 In OOP, a friend function of a class has exclusive access to which members of that class?

a)Private & protected members
b)Public & protected members
c)Private & public members
d)Private members
e)Protected members

Ans: A

In Networking, which of the following is NOT an example of application layer protocol?

a)HTTP
b)SMTP
c)FTP
d)TCP

Ans: D

If a machine needs 200 seconds to sort 200 bills by using bubble sort, how many bills will it sort in 800 seconds?

a)400
b)800
c)750
d)1000

Ans: B

If the disk queue of I/O block requests is 98,37,14,124,65,67 with the disk head initially at 32 how many disk moves are required when FCFS is used?

a) 310
b) 315
c) 321
d) 324

Ans: C

In which of the following page-replacement policies does Belady’s anomaly occur?

a)FIFO
b) Optimal
c)LRU
d)MRU

Ans: A

In OOP, which of the following is used to achieve runtime polymorphism?

a) A friend function
b) A virtual function
c)Operator overloading
d)Function overloading

Ans: B

In OOP, which of the following concepts allows a class object to be used inside another class?

a)Encapsulation
b)Abstraction
c)Composition
d)Inheritance

Ans: C

In an operating system, which of the following system programs combines the separately compiled modules of a program into a suitable form for execution?

a)Assembler
b)Linking loader
c)Cross compiler
d)Load and go

Ans: B

In SQL, which of the following commands is used to add a column to a table in a database?

a)ALTER TABLE <table name> ADD <column name>
b)MODIFY TABLE <table name> ADD <column name>
c)MODIFY TABLE <table name> INSERT <column name>
d)ALTER TABLE <table name> INSERT <column name>

Ans: A

Amazon wow Coding Questions and Answers 2023

Question: Parallel Columbus

Problem Statement: Nobel Prize-winning Austrian-Irish physicist Erwin Schrödinger developed a machine and brought as many Christopher Columbus from as many parallel universes he could. Actually he was quite amused by the fact that Columbus tried to find India and got America. He planned to dig it further.

Though totally for research purposes, he made a grid of size n X m, and planted some people of America in a position (x,y) [in 1 based indexing of the grid], and then planted you with some of your friends in the (n,m) position of the grid. Now he gathered all the Columbus in 1,1 positions and started a race.

Given the values for n, m, x, y, you have to tell how many different Columbus(s) together will explore you as India for the first time.

Remember, the Columbus who will reach to the people of America, will be thinking that as India and hence wont come further.

Function Description:

Complete the markgame function in the editor below. It has the following parameter(s):

Parameters:

Name Type Description
n Integer The number of rows in the grid.
m Integer The number of columns in the grid.
x Integer The American cell’s Row.
y Integer The American cell’s Column.

Constraints:

  • 1 <= n <= 10^2
  • 1 <= m <= 10^2
  • 1 <= x <= n
  • 1 <= y <= m

Input Format:

  • The first line contains an integer, n, denoting the number of rows in the grid.
  • The next line contains an integer m, denoting the number of columns in the grid.
  • The next line contains an integer, x, denoting the American cell’s row.
  • The next line contains an integer, y, denoting the American cell’s column.

Sample Cases

Sample Input 1

2

2

2

1

Sample Output 1

1

Explanation

The only way possible is (1,1) ->(2,1) -> (2,2), so the answer is 1.

C++ PROGRAM

#include <bits/stdc++.h>
using namespace std;
unordered_map<int,long long int> f;
 
long long int Fact(int n)
{
  if(f[n]) return f[n];
  return f[n]=n*Fact(n-1);
}
 
int main()
{
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  n-=1;m-=1;x-=1;y-=1;
  f[0]=f[1]=1;
  int p=(Fact(m+n)/(Fact(m)*Fact(n)));
  int imp=((Fact(x+y)/(Fact(x)*Fact(y)))*(Fact(m-x+n-y)/(Fact(m-x)*Fact(n-y))));
  cout<<p-imp;
}

PYTHON PROGRAM

import math
n=int(input())-1
m=int(input())-1
x=int(input())-1
y=int(input())-1

ans=math.factorial(n+m)
ans=ans//(math.factorial(n))
ans=ans//(math.factorial(m))

ans1=math.factorial(x+y)
ans1=ans1//(math.factorial(x))
ans1=ans1//(math.factorial(y))

x1=n-x
y1=m-y

ans2=math.factorial(x1+y1)
ans2=ans2//(math.factorial(x1))
ans2=ans2//(math.factorial(y1))
print(ans-(ans1*ans2))

Question: Amusement Park

Problem Statement: Aashay loves to go to WONDERLA , an amusement park. They are offering students who can code well with some discount. Our task is to reduce the cost of the ticket as low as possible.

They will give some k turns to remove the cost of one ticket where the cost of tickets are combined and given as string. Help Aashay in coding as he is not good in programming and get a 50%  discount for your ticket.

Constraints:

  • 1 <= number of tickets <= 10^5
  • 1 <= K <= number of tickets

Input Format for Custom Testing:

  • The first line contains a string,Tickets, denoting the given cost of each ticket.
  • The next line contains an integer, K, denoting the number of tickets that is to be removed.

Sample Cases:

  • Sample Input 1
    203
    3
  • Sample Output 1
    0

C++ PROGRAM

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int smallestNumber (string num, int k)
{
    if(num.length()<=k)
        return 0;
    unordered_map<char,int> pos;
    for(int i=0;i<num.length();i++)
   { pos[num[i]]=i;}
 
    string temp=num;
    sort(num.begin(),num.end());
    string ans=num.substr(0,num.length()-k);
    vector<int> v;
    for(int i=0;i<ans.length();i++)
    v.push_back(pos[ans[i]]);
 
    sort(v.begin(),v.end());
    string ret;
    for(int i=0;i<v.size();i++)
    {ret+=temp[v[i]];}
    int final=stoi(ret);
 
    return final;
}
int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    int ans;
    cout<<smallestNumber(s,k)%(int)(pow(10,9)+7);
    return 0;
}

PYTHON PROGRAM

import sys
n=input()
k=int(input())
n1=len(n)
if len(n)<=k:
 print(0)
 sys.exit()

a=''
i=0
while i<(n1-1) and k>0:
 if int(n[i])>int(n[i+1]):
  i+=1
  k-=1
  continue

 else:
  a+=n[i]
  i+=1

a+=n[i]
i+=1
if k>0:
 a=a[:-k]

if i<=(n1-1):
 while i<n1:
  a+=n[i]
  i+=1

print(int(a)%((10**9)+7))

Question: Self Sufficient

Problem Statement: Abhijeet is one of those students who tries to get his own money by part time jobs in various places to fill up the expenses for buying books. He is not placed in one place, so what he does, he tries to allocate how much the book he needs will cost, and then work to earn that much money only. He works and then buys the book respectively. Sometimes he gets more money than he needs so the money is saved for the next book. Sometimes he doesn’t. In that time, if he has stored money from previous books, he can afford it, otherwise he needs money from his parents.

Now His parents go to work and he can’t contact them amid a day. You are his friend, and you have to find how much money minimum he can borrow from his parents so that he can buy all the books.

He can Buy the book in any order.

Function Description:

Complete the function with the following parameters:

Name Type Description
N Integer How many Books he has to buy that day.
EarnArray[ ] Integer array Array of his earnings for the ith book
CostArray[ ] Integer array Array of the actual cost of the ith book.

Constraints:

  • 1 <= N <= 10^3
  • 1 <= EarnArray[i] <= 10^3
  • 1 <=  CostArray[i] <= 10^3

Input Format:

  • First line contains N.
  • Second N lines contain The ith earning for the ith book.
  • After that N lines contain The cost of the ith book.

Output Format: The minimum money he needs to cover the total expense.

Sample Input 1:

3

[3 4 2]

[5 3 4]

Sample Output 1:

3

Explanation:

At first he buys the 2nd book, which costs 3 rupees, so he saves 1 rupee. Then he buys the 1st book, that takes 2 rupees more. So he spends his stored 1 rupee and hence he needs 1 rupee more. Then he buys the last book.

C++ PROGRAM

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, ans =0,sum=0;
    cin>>n;
    vector<int> arr1(n),arr2(n);
    for(int i=0;i<n;i++) cin>>arr2[i];
    for(int i=0;i<n;i++) cin>>arr1[i];
    for(int i=0;i<n;i++) arr2[i]-=arr1[i];
 
    sort(arr2.begin(),arr2.end(),greater<int>());
    for(int i=0;i<n;i++)
    {
        sum+=arr2[i];
        if(sum<0)
        {ans+=abs(sum);sum=0;}
    }
    cout<<ans;
}

***BEST OFF LUCK***

We hope our article is informative. To stay ahead of the ever-increasing competition, you are strongly encouraged to download the previous year’s papers and start practicing. By solving these papers you will increase your speed and accuracy. For more information check Naukrimessenger.com website for exam patterns, syllabi, Results, cut-off marks, answer keys, best books, and more to help you crack your exam preparation. You can also take advantage of amazing Job offers to improve your preparation volume by joining in Telegram Channel page!!!