Rust (Coding) Assessment Test

Rust (Coding)

 60 Minutes
 3 Questions


Rust Coding Assessment: Mastering String Manipulation, Data Structures, and Dynamic Programming in Rust
This test assesses the candidate's ability to tackle coding challenges using Rust, with a focus on string manipulation, data structures, and dynamic programming techniques. The problems are carefully designed to evaluate problem-solving skills, logical thinking, and the ability to write efficient code using Rust's features.

Key Topics Covered:
String traversal and manipulation.
Implementation of dynamic programming for optimization problems.
Effective use of Rust?s standard library collections, such as HashMap and Vec.
Understanding and utilizing data structures to manage and manipulate data. Handling edge cases and ensuring code reliability.
Through these challenges, candidates will showcase their expertise in Rust, including their ability to work with core data structures and solve complex problems with optimal solutions.


Example Question:

Coding
Story:

A master thief is planning a heist at a jewelry store. The store has several vaults, each containing different numbers of jewels. However, the thief has limited time to break into the vaults, so he can only steal jewels from those not adjacent to each other. The thief wants to maximize the number of jewels he can steal without triggering the store?s alarm, which is activated when two adjacent vaults are robbed.

Task:
Write a function to help the thief determine the maximum number of jewels he can steal, given the number of jewels in each vault.

Function parameter:
vaults: A vector of integers where vaults[i] represent the number of jewels in the i-th vault.

The function should return the maximum number of jewels the thief can steal without robbing two adjacent vaults.

Example:
vaults = {5, 10, 15, 20, 25};

The function should return 45

Explanation:
For the vaults {5, 10, 15, 20, 25}, the thief has several options (some listed below):

Rob vault 0 and vault 3 = 5 + 20 = 25 jewels
Rob vault 1 and vault 4 = 10 + 25 = 35 jewels
Rob vault 0 and vault 2 and vault 4 = 5 +15+ 25 = 45 jewels (the optimal solution)