A cubic Bézier spline is defined by any four points: start, control-1, control-2, and end, which I will number 0, 1, 2, 3. For now we'll assume that the four points are distinct, and no three are in a straight line.
The curve can take three fundamentally different forms, depending on the direction of the turns between lines 0--1 and 1--2, and between 1--2 and 2--3, and whether 0--1 and 2--3 cross.
In type 1, both turns are to the right, or both are to the left, and 0--1 doesn't cross 2--3. That gives a curve like a, b or c in the questioner's example. In type 2, the first turn is to the left and the second to the right, or vice versa, giving a curve like d in the questioner's example, with a kink. In type 3, both turns are in the same direction, but lines 0--1 and 2--3 cross, giving a curve with a loop.
We can first categorise single cubic splines as one of three types, giving them a type string: ordinary ('' - the empty string), kinked ('K') and looped ('L').
However, example e is made of two smoothly joined cubic splines. To handle such sequences, we traverse them and create a string, appending a K for each kinked curve and an L for each looped curved. We also add a K for every join between two splines where the turn before the join is the opposite way from the turn after it: left then right, or right then left.
This gives us the type string 'K' for example e, matching it with d as desired.
We also allow a match where one type string is the reverse of the other: thus 'KL' matches 'LK'.