Posts

Showing posts from April, 2023

hacker rank time conversion js

  'use strict' ; const  fs = require( 'fs' ); process.stdin.resume(); process.stdin.setEncoding( 'utf-8' ); let  inputString =  '' ; let  currentLine =  0 ; process.stdin.on( 'data' ,  function (inputStdin) {     inputString += inputStdin; }); process.stdin.on( 'end' ,  function () {     inputString = inputString.split( '\n' );     main(); }); function  readLine() {      return  inputString[currentLine++]; } /*  * Complete the 'timeConversion' function below.  *  * The function is expected to return a STRING.  * The function accepts STRING s as parameter.  */ function  timeConversion(s) {      // Write your code here  ...

hacker rank practice q2 js+node

 Q.  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 The minimum sum is   and the maximum sum is  . The function prints 16 24 Function Description Complete the  miniMaxSum  function in the editor below. miniMaxSum has the following parameter(s): arr : an array of   integers Print Print two space-separated integers on one line: the minimum sum and the maximum sum of   of   elements. Input Format A single line of five space-separated integers. Constraints Output Format Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly  four  of the five integers. (The output can be greater than a 32 bit integer.) Sample Input 1 2 3 4 5 Sample Output 1...

hacker rank practice Q2 in c

 Hacker rank plus mi minus, min max, time conversion Question:  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   are acceptable. Example There are   elements, two positive, two negative and one zero. Their ratios are  ,   and  . Results are printed as: 0.400000 0.400000 0.200000 Function Description Complete the  plusMinus  function in the editor below. plusMinus has the following parameter(s): int arr[n] : an array of integers Print Print the ratios of positive, negative and zero values in the array. Each value should be printed on a separate line with   digits after the decimal. The function sho...