First sort by value, then sort by lexicography.
The point of this problem is to find the most appearance of s[i] - d[i].
Check one by one.
The most important is to consider all the situations that doesn't make a peak.