Count Triples with Difference
To view the original problem statement, pls check out the source image below 🐰
Imagine you have an empty collection of numbers, and you're given a list of instructions to add or remove numbers from this collection. Your task is to follow these instructions carefully and, after each one, count how many special groups of three numbers (we call them "triples") can be made from the numbers in your collection.
Here's how a triple works: you need to pick three numbers, let’s call them x, y, and z. For them to count as a triple, the difference between x and y must be the same as the difference between y and z. This means that if you rearrange the numbers correctly, they should form a nice pattern like x, y, z.
For each instruction, you either add a new number to your collection or remove all instances of a specific number from it. After every single instruction, you have to check how many triples you can make with the current set of numbers.
The story has a few rules to keep things interesting:
Your ultimate goal is to create a list of these counts after processing each instruction, showing how the number of possible triples changes as you add or remove numbers.
1Example 1
Constraints
Limits and guarantees your solution can rely on.
🐥🧡🐝