diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2024-01-08 14:54:58 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2024-01-08 14:54:58 +0800 |
| commit | e019e6886d406f9e111e67cb1cdbe39ec996bb2a (patch) | |
| tree | 7614dde91435b882f70c83213fb5c7301bed12bc /challenge-247/eric-cheung/python/ch-2.py | |
| parent | e94f52525bf99cded9ba76e696b691c7a657500b (diff) | |
| parent | 9a485c9bac8e3887b165d67c9aa81d71cdd42f01 (diff) | |
| download | perlweeklychallenge-club-e019e6886d406f9e111e67cb1cdbe39ec996bb2a.tar.gz perlweeklychallenge-club-e019e6886d406f9e111e67cb1cdbe39ec996bb2a.tar.bz2 perlweeklychallenge-club-e019e6886d406f9e111e67cb1cdbe39ec996bb2a.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-247/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-247/eric-cheung/python/ch-2.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-247/eric-cheung/python/ch-2.py b/challenge-247/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..61a6df3724 --- /dev/null +++ b/challenge-247/eric-cheung/python/ch-2.py @@ -0,0 +1,12 @@ +
+## strInput = "abcdbca" ## Example 1
+strInput = "cdeabeabfcdfabgcd" ## Example 2
+
+arrPairStr = [strInput[nIndxLoop : nIndxLoop + 2] for nIndxLoop in range(len(strInput) - 1)]
+
+arrUniqPair = list(set(arrPairStr))
+arrCountPair = [arrPairStr.count(strLoop) for strLoop in arrUniqPair]
+
+arrMaxPair = sorted([arrUniqPair[nIndx] for nIndx in range(len(arrCountPair)) if arrCountPair[nIndx] == max(arrCountPair)])
+
+print (arrMaxPair[0])
|
