Sunday, July 17, 2022
Duplicated Products | C# | HackerRank
Frequency of Max Value | C# | HackerRank
Equal Levels | HackerRank
Monday, May 30, 2022
Count String Permutations | HackerRank Certification
Count all possible N-length vowel permutations that can be generated based on the given conditions
Given an integer N, the task is to count the number of N-length strings consisting of lowercase vowels that can be generated based the following conditions:
- Each ‘a’ may only be followed by an ‘e’.
- Each ‘e’ may only be followed by an ‘a’ or an ‘i’.
- Each ‘i’ may not be followed by another ‘i’.
- Each ‘o’ may only be followed by an ‘i’ or a ‘u’.
- Each ‘u’ may only be followed by an ‘a’.a
nput: N = 1
Output: 5
Explanation: All strings that can be formed are: “a”, “e”, “i”, “o” and “u”.
Input: N = 2
Output: 10
Explanation: All strings that can be formed are: “ae”, “ea”, “ei”, “ia”, “ie”, “io”, “iu”, “oi”, “ou” and “ua”.
Condensed List | HackerRank Certification | Remove repeated node from a Singly Linked List
Given a list of integers, remove any nodes that have values that have previously occurred in the list and return a reference to the head of the list.
For e.g:
Linked List
Input : 3 --> 4 --> 3 --> 6
Output: 3 --> 4 --> 6
Sunday, April 17, 2022
Staircase | HackerRank | C#
This is a staircase of size :
#
##
###
####
Its base and height are both equal to . It is drawn using #
symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size .
Function Description
Complete the staircase function in the editor below.
staircase has the following parameter(s):
- int n: an integer
Print a staircase as described above.
Input Format
A single integer, , denoting the size of the staircase.
Constraints
.
Output Format
Print a staircase of size using #
symbols and spaces.
Note: The last line must have spaces in it.
Sample Input
6
Sample Output
#
##
###
####
#####
######
Explanation
The staircase is right-aligned, composed of #
symbols and spaces, and has a height and width of .
Solution
Plus Minus | HackerRank | C#
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 should not return a value.
Input Format
The first line contains an integer, , the size of the array.
The second line contains space-separated integers that describe .
Constraints
Output Format
Print the following lines, each to decimals:
- proportion of positive values
- proportion of negative values
- proportion of zeros
Sample Input
STDIN Function
----- --------
6 arr[] size n = 6
-4 3 -9 0 4 1 arr = [-4, 3, -9, 0, 4, 1]
Sample Output
0.500000
0.333333
0.166667
Explanation
There are positive numbers, negative numbers, and zero in the array.
The proportions of occurrence are positive: , negative: and zeros: .
SOLUTION
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary. Write a query calculating the amount of error (i.e.: average monthly salaries), and round it up to the next integer.
SELECT ROUND((AVG(Salary) - AVG(CAST(REPLACE(Salary, 0, '') AS int)))+1) FROM Employees;
horizontal ads
-
using System; using System.Collections.Generic; using System.IO; namespace Solution { public class NotesStore { public IDict...
-
using System ; using System . Collections . Generic ; using System . IO ; using System . Linq ; namespace Solution { public class ...
-
import React , { useState } from "react" ; import "./index.css" ; function CustomerList (){ const [ customer ,...