INTERVIEW QUESTION - Find out common letters between two strings Using Python

Sdílet
Vložit
  • čas přidán 21. 01. 2020
  • INTERVIEW QUESTION - Find out common letters between two strings Using Python
    GitHub Link :- github.com/netsetos/python_co...
    ~-~~-~~~-~~-~
    Please watch: "LRU Cache (With Python Code) "
    • LRU Cache Implementati...
    ~-~~-~~~-~~-~

Komentáře • 31

  • @hamzaahmad3387
    @hamzaahmad3387 Před rokem +18

    s1=input('enter a 1st string')
    s2=input('enter a 2nd string')
    s1 = set(list(s1))
    s2 = set(list(s2))
    common = list(s1.intersection(s2))
    print(common)

  • @sahilverma6160
    @sahilverma6160 Před 11 měsíci +10

    Print(set(a for a in "S1" if a in "S2"))

  • @XhantiMzozoyana-zs6rq
    @XhantiMzozoyana-zs6rq Před měsícem +1

    Love the intro, keep it coming🔥🔥

  • @telugutravellersonofgodsubbu

    If u keep carrier guidance that also help to all freshers mam 🙏

  • @sureshvishnu5213
    @sureshvishnu5213 Před 10 měsíci +10

    s1=input('enter a 1st string')
    s2=input('enter a 2nd string')
    common = set(s1).intersection(set(s2))
    print(common)

  • @vaibhavverma1340
    @vaibhavverma1340 Před rokem +3

    res = ''
    for st in s1:
    if st in s2 and st not in res:
    res+= st
    print(res)

  • @tanushreenagar3116
    @tanushreenagar3116 Před 5 měsíci

    Nice mam

  • @siddhigolatkar8558
    @siddhigolatkar8558 Před 8 měsíci

    thank you

  • @adithyanrk669
    @adithyanrk669 Před 3 lety

    awesome lecture mam

  • @shakthi2806
    @shakthi2806 Před 3 lety +1

    What happens if input is maane and naane

  • @sharmishthadevi7637
    @sharmishthadevi7637 Před 3 lety

    Nice video

  • @techiewithcamera
    @techiewithcamera Před 11 měsíci +1

    My Solution:
    def c_letters(w1, w2):
    set_w1=set(w1)
    set_w2=set(w2)
    print(set_w1 & set_w2)

  • @manivannan91
    @manivannan91 Před 3 měsíci

    please avoid the music ..

  • @Munna111
    @Munna111 Před 2 měsíci

    s1="naina"
    s2="reene"
    r=[]
    for i in s1:
    r.append(i)
    for j in set(s2):
    if j in r:
    print(j)

  • @gauravgirase8011
    @gauravgirase8011 Před 3 lety

    s1=set(input("Enter string 1"))

  • @DataEngineerPratik
    @DataEngineerPratik Před měsícem

    str1="NAINA"
    str2="REENE"
    common=""
    for i in str1:
    if i in str2:
    if i not in common:
    common+=i
    print(common)

  • @sahilkumar-zp7zv
    @sahilkumar-zp7zv Před rokem +5

    s1=input('Enter name1:')
    s2=input('Enter name2: ')
    t=[]
    for s in s1:
    if s in s2:
    if s in t:
    continue
    else:
    t.append(s)
    print(t)

    • @ansh912
      @ansh912 Před rokem

      This is also a good approach.

  • @user-ch8lb8jl9c
    @user-ch8lb8jl9c Před 6 měsíci +3

    a = "abbcd"
    b = "abbcdefg"
    z = set()
    for i in a:
    for j in b:
    if i == j:
    z.add(i)
    print(z)

  • @manjitjaiswar4990
    @manjitjaiswar4990 Před 3 lety +2

    s1=input('enter a 1st string')
    s2=input('enter a 2nd string')
    l=[ ]
    for ch in s1:
    if ch not in s2:
    pass
    else:
    l.append(ch)
    s3=' '.join(l)
    print('{} is the common elements in the both string {} and {}'.format(s3,s1,s2))

    • @arshiyashaik4982
      @arshiyashaik4982 Před 3 lety

      Output please.?

    • @manjitjaiswar4990
      @manjitjaiswar4990 Před 3 lety

      @@arshiyashaik4982 output:NN

    • @manjitjaiswar4990
      @manjitjaiswar4990 Před 3 lety +1

      Or else u can go for following logic as well..
      l1=list(input(' enter a 1st string'))
      l2=list(input(' enter a 2nd string'))
      s1=set(l1)
      s2=set(l2)
      print('The common element of above string is: ', ' '. Join(s1.intersection(s2)))

    • @arshiyashaik4982
      @arshiyashaik4982 Před 3 lety

      @@manjitjaiswar4990 ok

  • @bhaktirasangeeta5414
    @bhaktirasangeeta5414 Před 4 měsíci

    string1=input("Enter first string: Reene ")
    string2=input("Enter second string: Naina ")
    string1=set(string1)
    string2=set(string2)
    print(string1)
    print(string2)


    common_letters()

  • @bhupendrasingh3692
    @bhupendrasingh3692 Před 10 měsíci +2

    # Input two strings
    string1 = input("Enter the first string: ")
    string2 = input("Enter the second string: ")
    # Convert the strings into sets of unique characters
    set1 = set(string1)
    set2 = set(string2)
    # Find the common characters by taking the intersection of the sets
    common_characters = set1.intersection(set2)
    # Display the common characters
    print("Common characters between the two strings:", common_characters)

  • @super-eth8478
    @super-eth8478 Před rokem +2

    def common():
    a=input("Enter String 1: ")
    b=input("Enter String 2: ")
    ls=[]
    for i in a:
    for j in b:
    if i == j and i not in ls:
    ls.append(i)
    print(f"Common Letter between the two strings are : {ls}")