Professional Documents
Culture Documents
Test Logic Bootcamp 2024
Test Logic Bootcamp 2024
PERSONAL QUALIFICATION
TEST QUESTION
Read the test questions carefully. For answers, please immediately fill in the answers
below the related questions.
1.Answers :
#include <iostream>
#include <vector>
using namespace std;
vector<int> right_rotate(vector<int> nums, int rotate_count) {
rotate_count = rotate_count % nums.size();
vector<int> rotated_list(nums.size());
for (int i = 0; i < nums.size(); ++i) {
rotated_list[(i + rotate_count) % nums.size()] = nums[i];}
return rotated_list;}
int main() {
vector<int> input_list = {1, 2, 3, 4, 5};
int rotate_count = 2;
vector<int> result = right_rotate(input_list, rotate_count);
2. Write a program that accepts integer input. The numbers entered will be printed
sequentially downwards with some conditions:
· If the sequential number a multiple of both 2 and 3 then print TwoThree
· If the sequential number a multiple of 2 then print Two
· If the sequential number a multiple of 3 then print Three
· If the sequential number not a multiple of both 2 and 3 then print the value
Example:
Input:
Number input ⇒ 10
Output:
1
Two
Three
Two
5
TwoThree
7
Two
Three
Two
Explanation:
The numbers 6 are multiples both of 2 and 3, so print TwoThree
The numbers 2, 4, 8, 10 are multiples of 2, so print Two
The numbers 3, 9 are multiples of 3, so print Three
The numbers 1, 5, 7 aren’t multiples both of 2 or 3, so print the value
2.Answers :
#include <iostream>
void print_numbers(int n) {
for (int i = 1; i <= n; ++i) {
if (i % 2 == 0 && i % 3 == 0) {
std::cout << "TwoThree" << std::endl;
} else if (i % 2 == 0) {
std::cout << "Two" << std::endl;
} else if (i % 3 == 0) {
std::cout << "Three" << std::endl;
} else {
std::cout << i << std::endl;
}}}
int main() {
int jumlah_input;
std::cout << "Masukkan jumlah angka: ";
PT Rapid Teknologi Indonesia
Gedung EduCenter, Lt. 2 Unit 22298,
Jl. Sekolah Foresta, Kav Commercial International School Lot 2 No. 8,
BSD City, Tangerang Selatan, Banten.
🕿 021 5083 5637
std::cin >> jumlah_input;
print_numbers(jumlah_input);
return 0;}
3. Write a program to figure out if two rabbits that have different start point & velocity are
able to meet at the same location at the same time or not. If it is possible then print “YES”,
otherwise return “NO”.
Example
Input:
Position rabbit 1 ⇒ 0
Velocity rabbit 1 ⇒ 3
Position rabbit 2 ⇒ 4
Velocity rabbit 2 ⇒ 2
Output:
Result ⇒ “YES”
Explanation:
Position rabbit 1 before jump is 0, after 4 jumps the position will be 12
(0 + 3 + 3 + 3 + 3 = 12)
Position rabbit 2 before jump is 4, after 4 jumps the position will be 12
(4 + 2 + 2 + 2 + 2 = 12)
Because after 4 jumps rabbit 1 and rabbit 2 meet at position 12 then print
“YES”
3.Answers :
#include <iostream>
using namespace std;
5. Write a query to return customer_name (concat between first_name & last_name), age,
country_name (translate from country) and sort by oldest to youngest age.
Country List:
USA ⇒ United Stated
UK ⇒ United Kingdom
UAE ⇒ United Arab Emirates
Expected Result:
Goodluck!