File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ def solution (number , k ):
2+ max_num = []
3+
4+ for i in number :
5+ while max_num and k > 0 and max_num [- 1 ] < i :
6+ max_num .pop ()
7+ k -= 1
8+ max_num .append (i )
9+
10+ answer = '' .join (max_num [:len (number ) - k ])
11+
12+ return answer
Original file line number Diff line number Diff line change 1+ def solution (name ):
2+ count = 0
3+
4+ for a in name :
5+ count += min (ord (a ) - ord ('A' ), ord ('Z' ) - ord (a ) + 1 )
6+
7+ min_move = len (name ) - 1
8+
9+ for i in range (len (name )):
10+ next = i + 1
11+ while next < len (name ) and name [next ] == 'A' :
12+ next += 1
13+
14+ move = min (i , len (name ) - next ) * 2 + max (i , len (name ) - next )
15+ min_move = min (min_move , move )
16+
17+ count += min_move
18+
19+ return count
20+
21+
22+ print (solution ("JEROEN" ))
Original file line number Diff line number Diff line change 1+ def solution (routes ):
2+ routes .sort (key = lambda x : x [1 ])
3+
4+ count = 0
5+ camera = - 30001
6+
7+ for i in range (len (routes )):
8+ if routes [i ][0 ] > camera :
9+ count += 1
10+ camera = routes [i ][1 ]
11+
12+ return count
You can’t perform that action at this time.
0 commit comments