Solving Accenture Data Engineer Interview Question | Count of each alpha in strings in Python |

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • Combo course package : www.geekcoders...
    I have prepared many courses on Azure Data Engineering
    1. Build Azure End to. End Project
    www.geekcoders...
    2. Build Delta Lake project
    www.geekcoders...
    3. Master in Azure Data Factory with ETL Project and PowerBi
    www.geekcoders...
    4. Master in Python
    www.geekcoders...
    Check out my courses on Azure Data Engineering
    www.geekcoders...
    hastags
    tags
    #dataengineer #interviewquestions #python
    #hashtags #hastag #tags #tcs

КОМЕНТАРІ • 26

  • @mohdtoufique3786
    @mohdtoufique3786 4 місяці тому +5

    Hi Sagar! Thanks for the content my approach
    d={}
    for i in Input:
    if i in d:
    d[i]=d[i]+1
    else:
    d[i]=1
    print(list(d.values()))

  • @abhigyapranshu4791
    @abhigyapranshu4791 7 місяців тому +7

    Using Dictionary:
    s='bbbbcccaad'
    freq={}
    for key in s:
    if key in freq.keys():
    freq[key]+=1
    else:
    freq[key]=1
    print(list(freq.values()))

  • @wrestlingreality0323
    @wrestlingreality0323 18 годин тому

    from collections import Counter
    input="bbbbcccaad"
    ans=Counter(input)
    print(ans.values())

  • @kirtiagg5277
    @kirtiagg5277 5 місяців тому +1

    D={}
    Output=' '
    For ch in input :
    D[ch]=D.get(ch,0)+1
    For k,v in D.items():
    Output =output+ int(v)
    Print(output)

  • @mohdhammadkhan5570
    @mohdhammadkhan5570 7 місяців тому +2

    12:52 happiness after successfully running the code😂❤

  • @VITTHALPATIDAR-l1p
    @VITTHALPATIDAR-l1p Місяць тому +1

    I think using set and dictionary(from_keys) is also good one to solve this issue like that.
    st = 'bbbbaaccc'
    keys = set(list(st))
    dc = dict.fromkeys(keys,0)
    for i in dc.keys():
    for j in st:
    if i == j:
    dc[i]=dc[i] + 1
    print(dc)

    • @GeekCoders
      @GeekCoders  Місяць тому

      @@VITTHALPATIDAR-l1p yes thanks

  • @NITISHBHARDWAJONE
    @NITISHBHARDWAJONE 7 місяців тому +2

    We can use a dictionary too
    map = {}
    res=[]
    for i in input:
    map[i] = map.get(i, 0) + 1
    for (_,v) in map.items():
    res.append(v)
    print(res)

  • @starmscloud
    @starmscloud 7 місяців тому +1

    inputString:str = "bbbbcccaad"
    list({letter:inputString.count(letter) for letter in inputString}.values())
    Output :
    [4, 3, 2, 1]

  • @ravularamakrishna9962
    @ravularamakrishna9962 7 місяців тому

    string = "aaaabbbccd"
    def EveryAlpha(string):
    count = {}
    for i in string:
    if i in count:
    count[i] += 1
    else:
    count[i] = 1
    return list(count.values())
    print(EveryAlpha(string))

  • @arghyadhar9361
    @arghyadhar9361 5 місяців тому

    input="bbbbcccaad"
    #output=[4,3,2,1]
    def count(input):
    dict={}
    for i in input:
    if i in dict:
    dict[i]+=1
    else:
    dict[i]=1
    return list(dict.values())
    print(count(input))

  • @shashwatshekhar6867
    @shashwatshekhar6867 5 місяців тому

    input='bbbbcccaad'
    output_list=[]
    for i in input:
    if input.count(i) in output_list:
    pass
    else:
    output_list.append(input.count(i))
    print(output_list)

  • @AkshatGupta-ou7zz
    @AkshatGupta-ou7zz 6 місяців тому

    dictr = {}
    str1 = "bbbbcccaad"
    n = len(str1)
    for i in range(n):
    dictr[str1[i]]=0

    p1=0
    p2 =0
    for k in range(n):
    if str1[p1] == str1[p2]:

    dictr[str1[p1]] = dictr[str1[p1]]+1

    p1 = p1+1
    p2 = p2+1

    else:
    p1 = p1+1
    p2 = p2+1

  • @ayushsakure6098
    @ayushsakure6098 7 місяців тому +1

    Best he bhai 👍

  • @meetpatel2720
    @meetpatel2720 5 місяців тому

    Hey brother I'm getting stuck how to learn string and array in python for interview.
    Can you guide me any content?

  • @nirmitgupta3941
    @nirmitgupta3941 Місяць тому

    Bro, you're confusing yourself and us both. please stop.

    • @GeekCoders
      @GeekCoders  Місяць тому

      @@nirmitgupta3941 ok sir

    • @nirmitgupta3941
      @nirmitgupta3941 Місяць тому

      ⁠really sorry, did not mean to demotivate you. What you're doing is really commendable and takes lot of guts and hardwork.
      In this specific video, it looked like you're yourself trying to find a solution by trying different things and taking a difficult approach for an easy question.
      It owuld make much more sense if you figure out the solution yourself before recording.
      Please take this as a suggestion.
      Kudos to you and keep up the good work. ❤

    • @GeekCoders
      @GeekCoders  Місяць тому

      @@nirmitgupta3941 np sir, I didnt mind. I took as positive only. The reason is I don’t make a script before any video. We all are coders we all should know where we can do a mistakes

    • @pixiestar_
      @pixiestar_ Місяць тому

      Maybe coz he's not a very experienced guy but has only few years like a fresher

  • @vahayiioo
    @vahayiioo 7 місяців тому

    s='bbbbcccaad'
    l=[]
    rs=[]
    for i in s:
    if i not in rs:
    rs.append(i)
    for i in rs:
    l.append(s.count(i))
    print(l)
    simply and easy

    • @umakamatchi8249
      @umakamatchi8249 7 місяців тому

      input='aaaabbbccd'
      #iterate through the string and count each alpha using dict and then convert to list
      str_dict={}
      #looping through input
      for i in input:
      if i in str_dict:
      str_dict[i]+=1
      else:
      str_dict[i]=1
      print(str_dict)
      #To get list
      list_out=[]
      for (ch,value) in str_dict.items():
      list_out.append(value)
      print(list_out)

    • @prabhatgupta6415
      @prabhatgupta6415 3 місяці тому

      @@umakamatchi8249
      l='aaaabbbccd'
      d={i:l.count(i) for i in l}
      print(list(d.values()))