Hello, I was interviewing for a Junior Rust dev role and encountered this question:

Have been trying to find a solution but I can't seem to wrap my mind around it. Can anyone walk me through and help me implement it using Rust? Any help is greatly appreciated. Thanks.