A non-empty array A consisting of N integers is given. The amplitude of this array is defined as the largest possible difference between two of its elements, i.e.:
amplitude(A) = max{ A[P] − A[Q] : 0 ≤ P, Q < N }
Write a function:
class Solution { public int solution(int[] A); }
that, given a non-empty array A consisting of N integers, returns its amplitude.
For example, given array A such that:
A[0] = 10 A[1] = 2 A[2] = 44 A[3] = 15 A[4] = 39 A[5] = 20the function should return 42.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..1,000,000];
- each element of array A is an integer within the range [0..5,000,000].
Build a todo list component using Angular (v4). Export the todo list component as "TodoListComponent" (export class TodoListComponent).
Requirements:
1. Users should be able to add items to the list:
- Use an <input> element to accept user input for the todo list item.
- Use a <button> element to append the text in the <input> element as an item to the list and clear the <input> element.
- Use <li> elements for todo list items as children of <ul> element. Todo list items should not be empty and there can be multiple items with the same value.
2. Users should be able to mark/unmark items as completed:
- Cross (strikethrough) the <li> element when clicked to indicate that the item is completed and add "is-done" class to the <li> element.
- Undo the cross when the item is clicked again and remove "is-done" class from the <li> element.
3. Users should be able to track progress:
- Display a status message with the number of remaining tasks as "X remaining out of Y tasks", where X = the number of incomplete tasks, Y = the total number of items in list. Add "task-counter" class to the status message ("X remaining out of Y tasks") element.
Assessment/Tools:
- Use the animation below as a reference for your solution. You should focus on implementing the requirements; design/styling is not assessed and will not affect the score.
- The "Preview" tab will display your component. You can use it for testing purposes.
Available tools/packages:
- Angular (v4.3.6)
- RxJS (5.4.3)
- ZoneJs (0.8.4)
- core−js (2.4.1)
A rectangle is called rectilinear if its edges are all parallel to coordinate axes. Such a rectangle can be described by specifying the coordinates of its bottom-left and top-right corners.
Write a function
class Solution { public int solution(int K, int L, int M, int N, int P, int Q, int R, int S); }
that, given eight integers representing two rectilinear rectangles (one with lower-left corner (K, L) and upper-right corner (M, N), and another with lower-left corner (P, Q) and upper-right corner (R, S)), returns the area of their intersection. The function should return 0 if the intersection is a point or a line segment, or if the rectangles do not intersect. The function should return −1 if the area of the intersection exceeds 2,147,483,647.
For example, given integers:
K = 0 L = 2 M = 5 N = 10 P = 3 Q = 1 R = 20 S = 15the function should return 16.

The intersection of the two rectangles is a rectilinear rectangle whose lower-left corner is (3,2) and upper-right corner is (5,10), and its area equals 16.
Write an efficient algorithm for the following assumptions:
- K, L, M, N, P, Q, R and S are integers within the range [−2,147,483,648..2,147,483,647].