We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0813650 commit 4820826Copy full SHA for 4820826
rearrange_a_string_with_integers.py
@@ -0,0 +1,20 @@
1
+class Solution:
2
+ """
3
+ @param str: a string containing uppercase alphabets and integer digits
4
+ @return: the alphabets in the order followed by the sum of digits
5
6
+ def rearrange(self, str):
7
+ # Write your code here
8
+ count = 0
9
+ ret = []
10
+ for c in str:
11
+ if (c < '0') or (c > '9'):
12
+ ret.append(c)
13
+ else:
14
+ count += int(c)
15
+ ret.sort()
16
+ if count != 0:
17
+ ret.append(count.__str__())
18
+ return ''.join(ret)
19
+
20
+easy: https://www.lintcode.com/problem/rearrange-a-string-with-integers
0 commit comments