Write a bash script that prints the string "HELLO".
Input Format
There is no input file required for this problem.
Output Format
HELLO
Sample Input
-
Sample Output
HELLO
Explanation
-
SOLUTION:
This blog strives to provide answers to various problem statements in HackeRank.The blog is used only for educational purposes. This blog does not endorse copying answers.
Write a bash script that prints the string "HELLO".
Input Format
There is no input file required for this problem.
Output Format
HELLO
Sample Input
-
Sample Output
HELLO
Explanation
-
SOLUTION:
Jack and Daniel are friends. Both of them like letters, especially uppercase ones.
They are cutting uppercase letters from newspapers, and each one of them has his collection of letters stored in a stack.
One beautiful day, Morgan visited Jack and Daniel. He saw their collections. He wondered what is the lexicographically minimal string made of those two collections. He can take a letter from a collection only when it is on the top of the stack. Morgan wants to use all of the letters in their collections.
As an example, assume Jack has collected and Daniel has . The example shows the top at index for each stack of letters. Assemble the string as follows:
Jack Daniel result
ACA BCF
CA BCF A
CA CF AB
A CF ABC
A CF ABCA
F ABCAC
ABCACF
Note the choice when there was a tie at CA
and CF
.
Function Description
Complete the morganAndString function in the editor below.
morganAndString has the following parameter(s):
Returns
- string: the completed string
Input Format
The first line contains the an integer , the number of test cases.
The next pairs of lines are as follows:
- The first line contains string
- The second line contains string .
Constraints
Sample Input
2
JACK
DANIEL
ABACABA
ABACABA
Sample Output
DAJACKNIEL
AABABACABACABA
Explanation
The first letters to choose from are J and D since they are at the top of the stack. D is chosen and the options now are J and A. A is chosen. Then the two stacks have J and N, so J is chosen. The current string is DA. Continue this way to the end to get the string.
SOLUTION:
We define to be a permutation of the first natural numbers in the range . Let denote the value at position in permutation using -based indexing.
is considered to be an absolute permutation if holds true for every .
Given and , print the lexicographically smallest absolute permutation . If no absolute permutation exists, print -1
.
Example
Create an array of elements from to , . Using based indexing, create a permutation where every . It can be rearranged to so that all of the absolute differences equal :
pos[i] i |pos[i] - i| 3 1 2 4 2 2 1 3 2 2 4 2
Function Description
Complete the absolutePermutation function in the editor below.
absolutePermutation has the following parameter(s):
Returns
Input Format
The first line contains an integer , the number of queries.
Each of the next lines contains space-separated integers, and .
Constraints
Sample Input
STDIN Function ----- -------- 3 t = 3 (number of queries) 2 1 n = 2, k = 1 3 0 n = 3, k = 0 3 2 n = 3, k = 2
Sample Output
2 1
1 2 3
-1
Explanation
Test Case 0:
Test Case 1:
Test Case 2:
No absolute permutation exists, so we print -1
on a new line.
SOLUTION: