Consider a staircase of size n = 4:
1 | # |
Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size n.
Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line.
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
For example, the square matrix is shown below:
1 | 1 2 3 |
The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 17. Their absolute difference is |15 - 17| = 2.
Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.
We define the rating for Alice’s challenge to be the triplet a = (a[0], a[1], a[2])
, and the rating for Bob’s challenge to be the triplet b = (b[0], b[1], b[2])
.
Your task is to find their comparison points by comparing a[0] with b[0], a[1] with b[1], and a[2] with b[2].
Given an array of integers, find the sum of its elements.
For example, if the array ar = [1, 2 ,3], 1 + 2 + 3 = 6
, so return 6.
Update your browser to view this website correctly. Update my browser now