K (ngn/k), 15 bytes
{x@.=+|\2\!-#x} x:"abcdefg" !-#x / integers from -length-1 to -1 -7 -6 -5 -4 -3 -2 -1 2\!-#x / convert to base 2 -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 |\2\!-#x / maximum scan -1 -1 -1 -1 -1 -1 -1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 .=+|\2\!-#x / group identical columns (,0; 1 2; 3 4 5 6) x@.=+|\2\!-#x / index back into the input string (,"a"; "bc"; "defg")