• wonderlic tests
  • EXAM REVIEW
  • NCCCO Examination
  • Summary
  • Class notes
  • QUESTIONS & ANSWERS
  • NCLEX EXAM
  • Exam (elaborations)
  • Study guide
  • Latest nclex materials
  • HESI EXAMS
  • EXAMS AND CERTIFICATIONS
  • HESI ENTRANCE EXAM
  • ATI EXAM
  • NR AND NUR Exams
  • Gizmos
  • PORTAGE LEARNING
  • Ihuman Case Study
  • LETRS
  • NURS EXAM
  • NSG Exam
  • Testbanks
  • Vsim
  • Latest WGU
  • AQA PAPERS AND MARK SCHEME
  • DMV
  • WGU EXAM
  • exam bundles
  • Study Material
  • Study Notes
  • Test Prep

AMAZON ONLINE ASSESMENT EXAM QUESTIONS

EXAMS AND CERTIFICATIONS Jan 8, 2026
Preview Mode - Purchase to view full document
Loading...

Loading study material viewer...

Page 0 of 0

Document Text

PDF Download

AMAZON ONLINE ASSESMENT EXAM QUESTIONS

Actual Qs and Ans Expert-Verified Explanation

This Exam contains:

-Guarantee passing score -22 Questions and Answers -format set of multiple-choice -Expert-Verified Explanation

Question 1: public String mostCommonWord(String paragraph, String[] banned) {

String[] words = paragraph.replaceAll("[^a-zA-Z ]", "").split("\s+"); Set bannedSet = new HashSet<>(Arrays.asList(banned)); String common = ""; int max = 0; Map map = new HashMap<>(); for(int i = 0; i < words.length; i++) { String str = words[i].toLowerCase(); System.out.println(str); if(!bannedSet.contains(str)) { map.put(str, map.getOrDefault(str, 0) + 1); if(max < map.get(str)) { common = str; max = map.get(str); } } } return common; }

Answer:

Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique.Words in the list of banned words are given in lowercase, and free of punctuation. Words in the

paragraph are not case sensitive. The answer is in lowercase.

Example:

Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit." banned = ["hit"]

Output: "ball"

Explanation: "hit" occurs 3 times, but it is a banned word. "ball" occurs twice (and no other word does), so it is the most frequent non-banned word in the paragraph. Note that words in the paragraph are not case sensitive, that punctuation is ignored (even if adjacent to words, such as "ball,"), and that "hit" isn't the answer even though it occurs more because it is banned.

Question 2: double max = -1; // have a global max public double

maximumAverageSubtree(TreeNode root) { helper(root); return max; // return the calculated global maximum avg } public double[] helper(TreeNode root) {

if (root == null) return null; // base case: node is null

double sum = root.val; double numNode = 1; // from valid child we receive {average value, number of nodes} // add values to current sum and numNode double[] left = helper(root.left); double[] right = helper(root.right); if (left != null) { sum += left[0] * left[1]; numNode += left[1]; } if (right != null) { sum += right[0] * right[1]; numNode += right[1]; } // calculate the local average and replace the global if bigger double local = sum / numNode; if (local > max) { max = local; } // return {current average, number of nodes} return new double[] {local, numNode}; }

Answer:

Given the root of a binary tree, find the maximum average value of any subtree of that tree.(A subtree of a tree is any node of that tree plus all its descendants. The average value of a tree is the sum of its values, divided by the number of nodes.)

Input:

[5,6,1]

Output:

6.00000

Explanation:

For the node with value = 5 we have an average of (5 + 6 +

1) / 3 =

4.For the node with value = 6 we have an average of 6 / 1 = 6.For the node with value = 1 we have an average of 1 / 1 = 1.So the answer is 6 which is the maximum.

Question 3: class Point {

int x, y; public Point(int x, int y) { this.x = x; this.y = y; } } public int orangesRotting(int[][] grid) { Queue queue = new LinkedList<>(); int fresh = 0; for(int i = 0; i < grid.length; i++) { for(int j = 0; j < grid[0].length; j++) { if(grid[i][j] == 1) fresh++; if(grid[i][j] == 2) queue.add(new Point(i, j)); } } if(fresh == 0) return 0; int minute = 1; while(!queue.isEmpty()) { int size = queue.size(); while(size > 0) { Point curr = queue.poll(); int row = curr.x; int col = curr.y; if(isFresh(grid, row + 1, col)) { fresh--; if(fresh == 0) return minute; grid[row + 1][col] = 2; queue.add(new Point(row + 1, col)); } if(isFresh(grid, row - 1, col)) { fresh--; if(fresh == 0) return minute;

grid[row - 1][col] = 2; queue.add(new Point(row - 1, col)); } if(isFresh(grid, row, col + 1)) { fresh--; if(fresh == 0) return minute; grid[row][col + 1] = 2; queue.add(new Point(row, col + 1)); } if(isFresh(grid, row, col - 1)) { fresh--; if(fresh == 0) return minute; grid[row][col - 1] = 2; queue.add(new Point(row, col - 1)); } size--; } minute++; } return -1; } private boolean isFresh(int[][] grid, int row, int col) { if(row < 0 || row >= grid.length || col < 0 || col >= grid[0].length || grid[row][col] != 1) return false; return true; }

Answer:

  • Rotting Oranges
  • Given a 2D grid, each cell is either a zombie 1 or a human 0. Zombies can turn adjacent (up/down/left/right) human beings into zombies every hour. Find out how many hours does it take to infect all humans?

Example:

Input: [

[0, 1, 1, 0, 1],

[0, 1, 0, 1, 0],

[0, 0, 0, 0, 1],

[0, 1, 0, 0, 0]

]

Output: 2

Explanation: At the end of the 1st hour, the status of the grid: [

[1, 1, 1, 1, 1],

[1, 1, 1, 1, 1],

Download Study Material

Buy This Study Material

$11.99
Buy Now
  • Immediate download after payment
  • Available in the pdf format
  • 100% satisfaction guarantee

Study Material Information

Category: EXAMS AND CERTIFICATIONS
Description:

PDF Download AMAZON ONLINE ASSESMENT EXAM QUESTIONS Actual Qs and Ans Expert-Verified Explanation This Exam contains: -Guarantee passing score -22 Questions and Answers -format set of multiple-choi...

UNLOCK ACCESS $11.99