Leetcode 5345 by a vote of team rankings

A very simple data structures subject, the time of writing are not familiar with the stl card. . Mind blown up

Directly on the bar code:

 String rankTeams (Vector < String > & votes) { 
     // initialize a two-dimensional array to a certain space. . Vector
<Vector < int >> MP ( 27 , Vector < int > ( 27 , 0 )); int Len = votes.size (); int j_size votes = [ 0 ] .size (); for ( int I = 0 ; I <Len; I ++ ) { for ( int J = 0 ; J <j_size; J ++ ) { MP [votes [I] [J]- ' A ' ] [J] ++ ;
          // end coupled with the corresponding symbol, in addition to modifying the ordering rules may be modified corresponding to the key value of each MP [votes [I] [J]
- ' A ' ] [j_size ] = 26 is - (votes [I] [J] - ' A ' ); } } String ANS = "" ;
   Sort (mp.begin (), mp.end (), Greater
<Vector < int >> ()) ; for ( int I = 0 ; I <j_size; I ++ ) { ANS + = ( 26 is -mp [I] [j_size] +'A'); } return ans; }

 

Guess you like

Origin www.cnblogs.com/z1141000271/p/12393926.html