from __future__ import annotationsfrom collections import Counterfrom operator import itemgetterimport stringimport itertools as itdef swapVowels(s):s = list(string)vpos = []vchar = []for idx, char in enumerate(s):if char.lower() in ("a", "e", "i", "o", "u"):# or `if first in 'aeiou'`vpos.append(idx)vchar.append(char)for i in vpos:s[i] = vchar.pop()# element at s[i] is replaced with the last vowelcontained in vcharreturn "".join(s)string1 = "leetcode"print(swapVowels(string))# Can we construct ransom note from magazine?ransomNote = "aa"magazine = "aab"# Check to see if all items in ransomNote are contained in magazine# Reads like: For each i in ransomNote, is i contained in magazine# all(i in magazine for i in ransomNote)# counter1 = Counter(ransomNote)# counter2 = Counter(magazine)# not counter1 - counter2s = "loveleetcode"def find_first_non_repeating_char(s):alpha = string.ascii_lowercaseindex = [s.index(l) for l in alpha if s.count(l) == 1]return min(index) if len(index) > 0 else -1# def running_sum(lis):#running_sum = 0#sums = [None] * len(lis)#for indx, val in enumerate(lis):#running_sum += val