Cadence Design Systems interview question

Logical question and coding with design pattern