Flanking
Flanking is achieved when two characters using melee weapons are on the exact opposite sides of an enemy. In this situation, the flanking characters both have advantage against the flanked enemy. No other creatures engaged with the enemy benefit from your flanking. Some creatures are immune to flanking.
Flanking on Squares
When a creature and at least one of its allies are adjacent to an enemy and on opposite sides or corners of the enemy’s space, they flank that enemy, and each of them has advantage on melee attack rolls against that enemy.
When in doubt about whether two creatures flank an enemy on a grid, trace an imaginary line between the centers of the creatures’ spaces. If the line passes through opposite sides or corners of the enemy’s space, the enemy is flanked.