Google Interview Question

They asked me a DSA question to solve with structs