Filtering Data Table Duplicates based on a column value

Hello everyone,

I am trying to build a logic to filter data table which is as below.


It should look for Duplicate codes only if the type is “1A” and “1B” and filter them.

The output should be as below:

Let me know if there is a better way to do this apart from nesting through the data table.