Citadel Securities Interview Question

Implement a data structure that can efficiently handle operations X and Y on strings.