Skip to content

Instantly share code, notes, and snippets.

## Problem
```
Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers.
Then print the respective minimum and maximum values as a single line of two space-separated long integers.
Example
arr = [1,3,5,7,9]
@krButani
krButani / precisionproblems.md
Created June 16, 2024 03:43
precision problems

Problem

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with  places after the decimal.

Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to 10-4 are acceptable.

Example
arr = [1,1,0,-1,-1]
There are  elements, two positive, two negative and one zero. Their ratios are 2/5=0.400000,  2/5=0.400000 and 1/5=0.200000. Results are printed as:
@krButani
krButani / Staircase.md
Created June 15, 2024 05:41
Staircase

Problem

Staircase detail

This is a staircase of size n=4 :

   #
  ##
 ###
@krButani
krButani / comparethetriplatsarray.md
Created June 15, 2024 05:31
Compare the Triplets

Problem

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.

The rating for Alice's challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob's challenge is the triplet b = (b[0], b[1], b[2]).

The 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].

If a[i] > b[i], then Alice is awarded 1 point.
If a[i] < b[i], then Bob is awarded 1 point.
@krButani
krButani / sumofarrayelemnts.md
Last active June 15, 2024 05:27
Sum of Array Elements

Problem

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.

Constraints

0 <= ar[i] <= 1000


@krButani
krButani / 3ddiagonal.md
Last active June 15, 2024 05:27
3D array get diagonal value and calculate the absolute difference between the sums of its diagonals.

Problme

Given a square matrix, calculate the absolute difference between the sums of its diagonals.

For example, the square matrix  is shown below:

1 2 3
4 5 6
9 8 9