Problems that interest me or that I may need later and their solutions
1. HotDogProblem.java
Important: do not use packages; output files must not contain blank lines in the end.
Precondition:
The "input1.txt" file contains two different integers separated with comma.
The "input2.txt" file contains integers separated with space.
Task:
1) Read X and Y from "input1.txt" file
2) Go over integers from "input2.txt" file and:
- If integer can be divided by X print "Hot" in the "output.txt"
- If integer can be divided by Y print "Dog" in the "output.txt"
- If integer can be divided by both X and Y print "HotDog" in the "output.txt"
- Otherwise print the integer itself in the "output.txt"
Results in "output.txt" file must be separated with space.
Note:
Check the "input1.txt", "input2.txt" and "output.txt" files in "Tests" tab for an example
2. RewriteString.java
Precondition:
The "input.txt" file contains not empty string in lower case
Task:
1) Read string from the "input.txt" file
2) 2) Remove characters from the string that are repeated maximum number of times
3) If all characters are repeated the same number of times - keep the string as is
4) Print the result string to the "output1.txt" file
5) In the "output2.txt" file print each character of initial string and number of times it was repeated (in format "a:3"). These records must be separated with space and sorted by number of repetitions from greatest to lowest (if 2 characters have same number of repetitions - sort by character's code in ascending order).
3. New Companies.txt(SQL code)
Problem link - https://www.hackerrank.com/challenges/the-company/problem