3/27/24, 8:13 PM HackerRank Question - Maximum Profit
2h 3m left
1. Maximum Profit
An analyst is analyzing a stock over a period of n days. The price of the stock on the ith day is price[i], and the profit
ALL
obtained is denoted by profit[i]. The analyst wants to pick a triplet of days (i, j, k) such that (i < j < k) and price[i] <
price[j] < price[k] in such a way that the total profit, i.e. profit[i] + profit[j] + profit[k] is maximized.
Find the maximum total profit possible. If there is no valid triplet, return -1.
1 Example
Consider n = 5, price = [1, 5, 3, 4, 6], profit = [2, 3, 4, 5, 6].
An optimal triplet (considering 1-based indexing) is (3, 4, 5). Here 3 < 4 < 6, and total profit = 4 + 5 + 6 = 15, the
maximum possible. So, the answer is 15.
Function Description
Complete the function getMaximumProfit in the editor below.
getMaximumProfit has the following parameters:
int price[n]: the prices of the stock on each day
int profit[n]: the profits obtained from the stock on each day
Returns
long_int: the maximum possible total profit
Constraints
1 ≤ n ≤ 4000
1 ≤ price[i], profit[i] ≤ 109
9
Input Format For Custom Testing
10 Sample Case 0
Sample Input For Custom Testing
11 STDIN FUNCTION
----- --------
5 → price[] size, n = 5
12 2 → price = [2, 3, 1, 5, 9]
3
1
13 5
9
5 → profit[] size, n = 5
1 → profit = [1, 2, 6, 1, 5]
2
6
15 1
5
16 Sample Output
12
17
Explanation
An optimal triplet (considering 1-based indexing) is (3, 4, 5). Here 1 < 5 < 9, and total profit = 6 + 1 + 5 = 12.
Sample Case 1
https://www.hackerrank.com/test/7dip0q7jqnt/questions/a3bm5sf58rq 1/2
3/27/24, 8:04 PM HackerRank Question - Mirror Image 2
MADC Internship Program Generic English Taha Tahereddine
02 hours 12 mins Answered: 8 / 17
2. Mirror Image 2
ALL
Which option resembles the same sequence when placed in front of a mirror?
1
Pick ONE option
Clear Selection
10
3. Abstract Reasoning 4
11
Which figure comes next in the sequence?
12
13
Pick ONE option
14
15
16
17
Clear Selection
https://www.hackerrank.com/test/7dip0q7jqnt/questions/dh0soesf61b 1/2
3/27/24, 8:12 PM HackerRank Question - Logic Puzzles 12
MADC Internship Program Generic English Taha Tahereddine
02 hours 04 mins Answered: 8 / 17
ALL
4. Logic Puzzles 12
1
A hiker walks 15 km towards the north then 16 km towards the east then 15 km
towards the north. How far away and in which direction is the hiker with reference
to the starting point?
Pick ONE option
34 km northeast
34 km southeast
14 km northeast
14 km southeast
Clear Selection
Continue
10
11
12
https://www.hackerrank.com/test/7dip0q7jqnt/questions/7i5rl06g85l 1/2
3/27/24, 8:05 PM HackerRank Question - Correct Heap
MADC Internship Program Generic English Taha Tahereddine
02 hours 11 mins Answered: 8 / 17
5. Correct Heap
A heap is stored in an array but is imagined as a tree.
ALL
Which of the following is a valid tree representation of a maximum heap?
Pick ONE option
10
11
12
13
14
15
16
17
All of the above
Clear Selection
6. Tree Traversal 1
The postorder and preorder traversals of a binary tree are:
postorder : D E B F G C A
preorder : A B D E C F G
What is the inorder traversal of the tree?
https://www.hackerrank.com/test/7dip0q7jqnt/questions/3hnkq74r0qt 1/2
3/27/24, 8:06 PM HackerRank Question - Tree Traversal 1
MADC Internship Program Generic English Taha Tahereddine
02 hours 11 mins Answered: 8 / 17
ALL 6. Tree Traversal 1
The postorder and preorder traversals of a binary tree are:
postorder : D E B F G C A
preorder : A B D E C F G
1
What is the inorder traversal of the tree?
Pick ONE option
DBEAFCG
EDBGFCA
5
EDBFGCA
DEFGBCA
Clear Selection
9 Continue
10
11
12
https://www.hackerrank.com/test/7dip0q7jqnt/questions/968kojb1 1/2
3/27/24, 8:06 PM HackerRank Question - Time Complexity 1
MADC Internship Program Generic English Taha Tahereddine
02 hours 10 mins Answered: 8 / 17
7. Time Complexity 1
ALL What is the time complexity of this code?
int temp = 0;
for(int i = 1; i<=n; i++) {
for(int j = 1; j<=n; j+=i) {
for(int k = 1; k<=n; k+=2) {
temp++;
}
}
}
Pick ONE option
7
O(nlog(n))
O(nlog2(n))
9
O(n2log(n))
10
O(n2log2(n))
11
Clear Selection
12
13
14
8. Location Key
https://www.hackerrank.com/test/7dip0q7jqnt/questions/73ds9b5h2o4 1/2
3/27/24, 8:06 PM HackerRank Question - Location Key
MADC Internship Program Generic English Taha Tahereddine
02 hours 10 mins Answered: 8 / 17
ALL
8. Location Key
A hash function h defined h(key)=key%6 with linear probing is used to insert the
keys 19,20,18,25,11,19 into a table indexed from 0 to 5. What will be the
location of key 25?
Pick ONE option
3
7
2
9
4
10
Clear Selection
11
12
Continue
13
14
15
https://www.hackerrank.com/test/7dip0q7jqnt/questions/d8mn8atnao 1/2
3/27/24, 8:07 PM HackerRank Question - ML- Tweets Classification
MADC Internship Program Generic English Taha Tahereddine
02 hours 09 mins Answered: 8 / 17
9. ML- Tweets Classification
ALL
Submit only if you are interested in Data Science internship
This task is expected to be done off-line, just confirm in your answer that you will be sending the challenge answer within a week, the task report and source code should
be sent to apply_ma@oracle.com and cc mohamed.ez.zarghili@oracle.com.
1
1- Description
This is a tweet classification task where the tweets could be either Politics or Sports (i.e., binary classification). The following subsections provide the details concerning
this specific task.
1.1 Task details
The competition is hosted at the following kaggle link: https://www.kaggle.com/c/deeptweets/ and you can join the task using the following
link: https://www.kaggle.com/t/9a952f61d17f447c8f61ae5e7eddf399. It is important to abide by the rules of the task which are also mentioned
in https://www.kaggle.com/c/deeptweets/rules.
1.2 Kaggle account details
7
You should create a new Kaggle account with your username as ORCL-DS-APP. While submitting your score, please use the following team-name: PGX- DS-T<RAND-
NUM> where RAND-NUM is some random number between 1 to 100000 (clearly mention your team-name in your task report).
9 1.3 Datasets and leaderboard
10 You would find our benchmark score in the leaderboard (https://www.kaggle.com/c/deeptweets/leaderboard) and the train+test datasets (along with sample submission
format in Kaggle) in the data section ( https://www.kaggle.com/c/deeptweets/data ).
11
1.4 Task reports
12
Once you have completed the task, then you need to send the complete working code to apply_ma@oracle.com and cc mohamed.ez.zarghili@oracle.com. (which should
be reproducible) along with the task report. The task report contains the details regarding:
13
1. Feature Extraction.
14
2. Model Training.
3. Hyper-parameter tuning.
15
4. Performance (including breakup for feature extraction, model training, and output prediction using the trained model).
16 5. what other approaches do you think could improve over your current solution (if you have more time).
17
1.5 Contact
For any questions regarding the task, please contact rhicheek.patra@oracle.com or damien.hilloulin@oracle.com, and CC mohamed.ez.zarghili@oracle.com.
Please provide your answer in the following editor
https://www.hackerrank.com/test/7dip0q7jqnt/questions/7b2inn5gdpj 1/2
3/27/24, 8:07 PM HackerRank Question - Ansible: Docker Deployment
2h 9m left Terminal
10. Ansible: Docker
Deployment
ALL
The task is to complete a file stub
"/home/ubuntu/860700-ansible-docker-
deployment/playbook.yml" with one or
more steps that do the following:
Runs a new Docker container from
the "nginx" image (latest tag) on port
"80" using the Ansible module
"docker_container".
7
Note
The completed solution will be
evaluated in a new, clean
environment. Be sure everything is in
9 the "/home/ubuntu/860700-ansible-
docker-deployment" folder.
All the tasks should be done within a
10
simple "sudo solve" execution
invoked from the question directory.
11 Ansible is already installed.
You have sudo access.
12
Grading
13
The execution result of "sudo solve"
invoked from the question directory
solves the task.
14
The execution result of "wget -qO-
http://localhost:80" shows a valid
15 nginx "Welcome Page".
The Ansible module
16 "docker_container" is used.
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/d0n61kldj9q 1/2
3/27/24, 8:08 PM HackerRank Question - Docker: Frontend Deployment Cleanup
2h 8m left Terminal
11. Docker: Frontend
Deployment Cleanup
ALL
When you finished work on frontend
deployment update process, you
decided to make a cleanup process from
redundant Docker images and
containers left after switching the
application stack.
Complete the file stub
"/home/ubuntu/1319467-docker-
frontend-deployment-cleanup/script.sh"
7 with one or more steps that do the
following.
Eliminate the Docker container named
"frontend".
Eliminate all the Docker images
9
referenced to the "httpd" Dockerhub
repository.
10
All the Docker entities will be
dynamically recreated during evaluation.
11
Their Docker ids MUST NOT be
hardcoded!
12
Note:
The completed solution will be
13 evaluated in a new, clean environment.
ANY CHANGES MADE MANUALLY WILL
BE LOST. ONLY CHANGES TO THE
14 "script.sh" FILE IN
"/home/ubuntu/1319467-docker-
frontend-deployment-cleanup" WILL
15 BE CARRIED TO THE NEW
ENVIRONMENT.
16 The result of "sudo solve", invoked
from the question directory, should
solve the task.
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/221to5na4br 1/2
3/27/24, 8:09 PM HackerRank Question - Linux: Archive Alteration
2h 8m left Terminal
12. Linux: Archive
Alteration
ALL
Complete the file stub
"/home/ubuntu/894524-linux-archive-
alteration/script.sh" with one or more
steps that do the following:
Extract the archive
"/home/ubuntu/894524-linux-archive-
alteration/archive.tar"
In all the extracted log files,
7 eliminate all the empty files,
append the ".log" extension to all the
remaining files, then create a new
archive named "/tmp/archive.tar".
9 Note
The completed solution will be
evaluated in a new, clean
10
environment. Be sure everything is in
the "/home/ubuntu/894524-linux-
archive-alteration" folder.
11
All the tasks should be done within a
simple "sudo solve" execution
12 invoked from the question directory.
You have sudo access.
13
Grading
The execution result of "sudo solve"
invoked from the question directory
solves the task.
15
16
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/lchb6281h6 1/2
3/27/24, 8:09 PM HackerRank Question - Terraform: Variables
2h 7m left Terminal
13. Terraform: Variables
You need to deploy a web application using
ALL Terraform.
Complete a file stub
"/home/ubuntu/1063728-terraform-
variables/main.tf" using HCL with one or
more steps that do the following:
Declare the variable "dns_resolver", with
type "set" of "strings" and default values
"8.8.8.8" and "8.8.4.4".
Declare the variable "port", with type
"integer" and default value "53".
Declare the variable "token", with type
7 "string" and an empty default value.
Declare the variable "use_cache", with type
"bool" and the default value "true".
Output the values of the "dns_resolver",
"port", "token" and "use_cache" variables
9 using "output" block. The output of the
"token" variable must be declared as
"sensitive".
10
Note
11
The completed solution will be evaluated in
a new, clean environment. Be sure
everything is in the
12
"/home/ubuntu/1063728-terraform-
variables" folder.
13 All the tasks should be done within a
simple "sudo solve" execution invoked from
the question directory.
You have sudo access.
15
Grading
The execution result of "sudo solve"
16
invoked from the question directory solves
the task.
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/6ooom38gj1g 1/2
3/27/24, 8:10 PM HackerRank Question - Git: Initial Commit
2h 7m left Terminal
14. Git: Initial Commit
You are working on the application
ALL development process and need to
commit your changes to Git.
Using the existing Git repository
"/home/ubuntu/1326005-git-initial-
commit":
Set up a Git username at the
repository level (not globally!), set it to
"Hacker Developer".
7
Set up a Git email address at the
repository level (not globally!), set it to
"hacker.developer@hackercompany.c
om".
Commit all available files in
9
"/home/ubuntu/1326005-git-initial-
commit" directory to the Git
repository with the message "Initial
10
Implementation"
Push all to the remote origin
11
Note:
12 The completed solution will be
evaluated in a new, clean
environment. ONLY CHANGES IN
"/home/ubuntu/1326005-git-initial-
13
commit" WILL BE CARRIED TO THE
NEW ENVIRONMENT. ALL CHANGES
OUTSIDE THIS DIRECTORY WILL BE
LOST.
15
16
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/3c62bnn06pp 1/2
3/27/24, 8:10 PM HackerRank Question - Terraform: Docker
2h 6m left Terminal
15. Terraform: Docker
You need to deploy a web application
ALL using Terraform.
Complete a file stub
"/home/ubuntu/1064389-terraform-
docker/main.tf" using HCL with one or
more steps that do the following:
Initialize the provider plugin
"kreuzwerker/docker", at version
"2.11.0".
Using a "docker_container" resource,
7
create a new docker container from an
"nginx" image on "latest" tag, with the
container name "web" and a published
port "80".
9 Note
The completed solution will be
10 evaluated in a new, clean environment.
Be sure everything is in the
"/home/ubuntu/1064389-terraform-
11 docker" folder.
All the tasks should be done within a
simple "sudo solve" execution invoked
12
from the question directory.
You have sudo access.
13
Grading
The execution result of "sudo solve"
invoked from the question directory
solves the task.
15
The execution result of "wget -qO-
http://localhost" shows a valid nginx
16 "Welcome Page".
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/ebro9ep3h1k 1/2
3/27/24, 8:11 PM HackerRank Question - Kubernetes: Secrets
2h 6m left Terminal
16. Kubernetes: Secrets
A web application built on Kubernetes
ALL must be deployed. Complete the file
stub "/home/ubuntu/924270-
kubernetes-secrets/script.sh" with one
or more steps that do the following:
Create a new generic secret
"application" with the key "checksum"
and the value from the host's
environment variable
"APPLICATION_CHECKSUM", in the
7 "hacker-company" namespace.
Create a new generic secret
"deployment" with the key "ssh_key"
and the value from the host's ssh
private key "/id_rsa.pub", in the
"hacker-company" namespace.
9
Note
10
The completed solution will be
evaluated in a new, clean
11 environment. Be sure everything is in
the "/home/ubuntu/924270-
kubernetes-secrets" folder.
12
All the tasks should be done within a
simple "sudo solve" execution
13 invoked from the question directory.
You have sudo access.
Grading
15 The execution result of "sudo solve"
invoked from the question directory
solves the task.
16
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/7gk5fjnc3rr 1/2
3/27/24, 8:11 PM HackerRank Question - Ansible: HackerAPI frontend provision
2h 5m left Terminal
17. Ansible: HackerAPI
frontend provision
ALL
While working on initial production
deployment of the "HackerAPI" software
stack, you have decided to implement
frontend provision logic as a separate
playbook.
Complete the file stub
"/home/ubuntu/1305033-ansible-
hackerapi-frontend-
provision/playbook.yml" with one or
more steps that do the following.
7 Using a builtin core "apt" and
"apt_repository" modules:
remove an obsolete "apache2"
package
with all the dependencies
9 with purging of configuration
files
install a new "nginx" package
10
from "ppa:nginx/stable" PPA
at version "1.18.0-
11 3ubuntu1+bionic1"
Note:
12
The completed solution will be
evaluated in a new, clean environment.
13 ANY CHANGES MADE MANUALLY WILL
BE LOST. ONLY CHANGES TO THE
"playbook.yml" FILE IN
"/home/ubuntu/1305033-ansible-
hackerapi-frontend-provision" WILL BE
CARRIED TO THE NEW ENVIRONMENT.
15 The result of "sudo solve", invoked from
the question directory, should solve the
task.
16
17
Submit
https://www.hackerrank.com/test/7dip0q7jqnt/questions/8tagjf62d19 1/2