1069

Removing . has no consequences, so they can be ignored, which turns the inputs into:

<><<>>
<<<<<<<<>

The question now becomes “how many balanced pairs of brackets are on a string”, which is easily solvable with a stack.

However, checking the stack.c solution you’ll notice that the stack is only being used to check if we have seen a < before, and can be replaced with a simple counter. If we were dealing with multiple types of brackets, a counter wouldn’t be enough (e.g. [()]{}{[()()]()}).

Solutions

stack.c

Pushes < into a stack, pops the top of the stack when a > is found, incrementing the result.

counter.c

Counts how many < have appeared so far, decrements the counter when a > is found, incrementing the result.