Hướng dẫn taru and odd string in python - taru và chuỗi lẻ trong python

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    ĐọcMethod #1 : Using loop This is brute force way in which this task can be performed. In this, we first split the string to words and then perform iteration to get the odd length words. 

    Python3

    Bàn luận

    Đôi khi, trong khi làm việc với Python, chúng ta có thể gặp vấn đề trong đó chúng ta cần trích xuất các từ dài nhất định từ một chuỗi. Đây có thể là trích xuất các từ dài lẻ từ chuỗi. Điều này có thể có ứng dụng trong nhiều lĩnh vực bao gồm lập trình hàng ngày. Hãy thảo luận về những cách nhất định trong đó nhiệm vụ này có thể được thực hiện. Phương pháp số 1: Sử dụng vòng lặp Đây là cách vũ phu trong đó nhiệm vụ này có thể được thực hiện. Trong đó, trước tiên chúng tôi chia chuỗi thành các từ và sau đó thực hiện lặp lại để có được các từ dài lẻ. & Nbsp;

    test_str = "gfg is best of geeks"

    print["The original string is : "

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    1

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    2=
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    4

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    7

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    7
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    8

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    1
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    2223
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    4
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    5

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']

    print[

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    0
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    2
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    3Method #2 : Using list comprehension This task can also be performed using list comprehension. In this, we perform the task in similar way as above. Just the difference is that its a one-liner. 

    Python3

    Bàn luận

    Đôi khi, trong khi làm việc với Python, chúng ta có thể gặp vấn đề trong đó chúng ta cần trích xuất các từ dài nhất định từ một chuỗi. Đây có thể là trích xuất các từ dài lẻ từ chuỗi. Điều này có thể có ứng dụng trong nhiều lĩnh vực bao gồm lập trình hàng ngày. Hãy thảo luận về những cách nhất định trong đó nhiệm vụ này có thể được thực hiện. Phương pháp số 1: Sử dụng vòng lặp Đây là cách vũ phu trong đó nhiệm vụ này có thể được thực hiện. Trong đó, trước tiên chúng tôi chia chuỗi thành các từ và sau đó thực hiện lặp lại để có được các từ dài lẻ. & Nbsp;

    test_str = "gfg is best of geeks"

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    7
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    8

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    1
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    2223
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    4
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    5

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']

    print[

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    0
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    2
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    3

    Đầu ra: & nbsp;O[n]

    & nbsp; Phương pháp số 2: Sử dụng danh sách Hiểu biết Nhiệm vụ này cũng có thể được thực hiện bằng cách sử dụng danh sách hiểu. Trong đó, chúng tôi thực hiện nhiệm vụ theo cách tương tự như trên. Chỉ là sự khác biệt là nó là một lớp lót. & NBSP;O[n]


    Với một loạt các chuỗi chữ thường, nhiệm vụ là tìm số lượng chuỗi khác biệt. Hai chuỗi là khác biệt nếu, khi áp dụng các hoạt động sau trên một chuỗi, chuỗi thứ hai không thể được hình thành. & Nbsp; & nbsp;

    • Một ký tự trên chỉ số lẻ chỉ có thể được hoán đổi với một ký tự khác trên chỉ số lẻ.
    • Một ký tự trên chỉ mục có thể được hoán đổi với một ký tự khác chỉ trên chỉ mục.

    Examples:    

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 

    Một giải pháp đơn giản là chạy hai vòng. Vòng lặp bên ngoài chọn một chuỗi và vòng lặp bên trong kiểm tra xem có chuỗi trước đó có thể được chuyển đổi thành chuỗi hiện tại bằng cách thực hiện các phép biến đổi được phép. Giải pháp này yêu cầu thời gian O [N2M] trong đó n là số chuỗi và M là số lượng ký tự tối đa trong bất kỳ chuỗi nào.simple solution is to run two loops. The outer loop picks a string and the inner loop checks if there is a previously string which can be converted to a current string by doing allowed transformations. This solution requires O[n2m] time where n is the number of strings and m is the maximum number of characters in any string.

    Một giải pháp hiệu quả tạo ra một chuỗi được mã hóa cho mỗi chuỗi đầu vào. Các mã được mã hóa có số lượng các ký tự được định vị chẵn và lẻ được phân tách bằng một dấu phân cách. Hai chuỗi được coi là giống nhau nếu các chuỗi được mã hóa của chúng giống nhau, thì khác thì không. Khi chúng ta có một cách để mã hóa các chuỗi, vấn đề sẽ được giảm xuống để đếm các chuỗi được mã hóa riêng biệt. Đây là một vấn đề điển hình của băm. Chúng tôi tạo một bộ băm và, từng cái một, lưu trữ mã hóa của chuỗi. Nếu một mã hóa đã tồn tại, chúng ta bỏ qua chuỗi. Mặt khác, chúng tôi lưu trữ mã hóa trong băm và số lượng tăng của các chuỗi riêng biệt. & Nbsp;efficient solution generates an encoded string for every input string. The encoded has counts of even and odd positioned characters separated by a separator. Two strings are considered same if their encoded strings are the same, then else not. Once we have a way to encode strings, the problem is reduced to counting distinct encoded strings. This is a typical problem of hashing. We create a hash set and, one by one, store encodings of strings. If an encoding already exists, we ignore the string. Otherwise, we store encoding in hash and increment count of distinct strings. 

    Implementation:

    C++

    "gfg is best of geeks"1

    "gfg is best of geeks"2 "gfg is best of geeks"3 "gfg is best of geeks"4

    "gfg is best of geeks"5 "gfg is best of geeks"6

    "gfg is best of geeks"7"gfg is best of geeks"8 "gfg is best of geeks"9"gfg is best of geeks"5 print1

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"5 print4

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"5 print7

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9print9[0[1[2

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9print9[5[1[7

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5 "The original string is : "2

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"8 "The original string is : "5

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 "The original string is : "8

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    00
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    04

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    06
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    12
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    13
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    19

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    21

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    27

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    36

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    "gfg is best of geeks"5

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    39"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    41

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    44

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    46

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    51

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"8
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    54

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    56
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    57

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    60

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    62

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    64

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    71

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    "gfg is best of geeks"5

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    74

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    76
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    77
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    81
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    83
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    84

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    86
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    88
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    89

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    92[1
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    94[1
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    96

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    98
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    99
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Java

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    02
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    03

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    02
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    05

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    06
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    07

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    10
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    11
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    15"gfg is best of geeks"8
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    17

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    20
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    23

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    26
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    23

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    34
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    36

    "The original string is : "9"gfg is best of geeks"8 "The original string is : "5

    "The original string is : "9

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    42
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    43
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    444____235
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    46

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    00
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    04

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    06
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    60
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    13
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    34
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    69

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    21

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    27

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    36

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    92"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    41

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    97
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    99

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    01
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    03

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    34
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    10

    "The original string is : "9

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    13

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    15

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    64

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    71

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    28
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    30
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    31

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    33
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    77
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    81
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    83
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    84

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    86
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    88
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    89

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    49

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    51

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Python3

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    55=
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    11

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    58
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    59

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    61=
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    63
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    65
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    66
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    67

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    69=
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    63
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    65
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    66
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    67

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    7
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    80[
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    1
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    83

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    85=
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    87

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    90
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    43
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    92

    "The original string is : "9

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    94
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    95
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    96______397

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    04
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    5

    "The original string is : "9test_str 09

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    95
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    96______397

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9test_str 21=
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    13

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    7
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    80test_str 29

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6test_str 21
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    2test_str 35

    Các

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6test_str 21
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    2test_str 49

    Các

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6test_str 21
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    0
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    2test_str 49

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35 test_str 60

    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    58 test_str 62test_str 63test_str 64

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9test_str 66=
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    35

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9test_str 70= test_str 72test_str 73

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    7
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    80test_str 79

    "The original string is : "9test_str 89test_str 63test_str 91

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 test_str 82test_str 63__

    "The original string is : "9test_str 66____10105

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    43

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35 test_str 99

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 =01== =04
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    5

    =16

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    83
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    86
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    88=4

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9test_str 63 =
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    63
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    77
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78__

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9print=32test_str 63=34

    C#

    "gfg is best of geeks"2 =36

    "gfg is best of geeks"2 =38

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    06 =40

    =41

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08 "gfg is best of geeks"5 "gfg is best of geeks"6

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    15"gfg is best of geeks"8=50

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9=41

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5 =55
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    23

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5 =61
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"5
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    23

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5 =69

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6=41

    "The original string is : "9"gfg is best of geeks"8 =74

    "The original string is : "9

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 =77

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47=79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    04

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47=85
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    02

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    60
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    13
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5 =98

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6=41

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    21

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    27

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    36

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08 "gfg is best of geeks"5 "gfg is best of geeks"23"gfg is best of geeks"5 "gfg is best of geeks"25

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9=41

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    44

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"32
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"34

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5 "gfg is best of geeks"39

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6=41

    "The original string is : "9

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 "gfg is best of geeks"44

    "The original string is : "9=41

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47"gfg is best of geeks"48

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    64

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    71

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    28
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    30 "gfg is best of geeks"64

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9=41

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"68
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    77
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    81
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    84

    "gfg is best of geeks"75

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    83
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    86
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    88
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    89

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5 "gfg is best of geeks"84

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"86

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    JavaScript

    "gfg is best of geeks"90

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"92

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9"gfg is best of geeks"94 "gfg is best of geeks"95

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"97

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"99

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 print02

    "The original string is : "9print04

    "The original string is : "9

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    0 "The original string is : "8

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47print09
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01print11

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    04

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47print15
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    01print11

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6print21
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    13
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    14

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 print26

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    21

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    27

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    23
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    24
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    25

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    36

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08 "gfg is best of geeks"5 "gfg is best of geeks"23"gfg is best of geeks"5 "gfg is best of geeks"25

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6print50

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    44

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"32
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    21 "gfg is best of geeks"34

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    5 ["gfg is best of geeks"5 "gfg is best of geeks"39

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47print64print61print66

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    47
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    64

    "The original string is : "9

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    35
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    71

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    10

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6print79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    77
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    79
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    81
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    78
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    83
    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    84

    The original string is : gfg is best of geeks
    The odd length strings are : ['gfg', 'geeks']
    9
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    28
    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    08
    strings as the third string cannot be converted to the 
    first.
    
    Input  : arr[] = {"abc", "cba"}
    Output : 1 
    30 "gfg is best of geeks"64

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6print94

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6print96

    print97

    Input  : arr[] = {"abcd", "cbad", "bacd"}
    Output : 2
    The 2nd string can be converted to the 1st by swapping 
    the first and third characters. So there are 2 distinct 
    6"gfg is best of geeks"5 "gfg is best of geeks"84: O[n] 
    Auxiliary Space : O[1]

    JavaScript


    Làm thế nào để bạn xác định xem một chuỗi là lẻ hay thậm chí trong Python?

    Các mã cần thiết được cung cấp dưới đây. num = int [input [nhập bất kỳ số nào để kiểm tra xem nó là lẻ hay thậm chí: Đầu ra] đầu ra: Nhập bất kỳ số nào để kiểm tra xem nó là lẻ hay thậm chí: 887 887 là lẻ.if [num % 2] == 0: print [“The number is even”] else: print [“The provided number is odd”] Output: Enter any number to test whether it is odd or even: 887 887 is odd.

    Làm cách nào để in các ký tự lẻ trong một chuỗi?

    Để in các ký tự lẻ, chúng ta cần bắt đầu với các ký tự bắt đầu ở vị trí 1 với chênh lệch là 2. toán tử cắt trong trường hợp này sẽ được viết là STR [1 :: 2]. Chỉ mục được khởi tạo thành 0. A WHER Loop lặp lại trên chuỗi bắt đầu từ 0 đến chiều dài của chuỗi được tính toán bằng hàm LEN.start with characters starting at position 1 with a difference of 2. Slicing operator in this case will be written as str[1::2] . index is initialized to 0. A while loop iterates over the string starting from 0 till the length of string which is calculated using len function.

    Làm cách nào để in một danh sách các phần tử có độ dài chuỗi lẻ?

    Bước 1: Khai báo và khởi tạo một mảng.Bước 2: Tính độ dài của mảng được khai báo.Bước 3: Vòng lặp qua mảng bằng cách khởi tạo giá trị của biến số I I sang 0 sau đó tăng giá trị của nó lên 2, tức là, i = i+2.Bước 4: In các yếu tố có mặt ở các vị trí lẻ.

    Làm thế nào để bạn in một chữ cái chẵn trong một chuỗi trong Python?

    Phương pháp: Tìm các từ dài thậm chí bằng cách sử dụng cho vòng lặp và nếu câu lệnh và không sử dụng hàm def.Đầu tiên phân chia chuỗi đã cho bằng cách sử dụng hàm chia [] và sau đó lặp lại các từ của chuỗi bằng cách sử dụng vòng lặp.Tính độ dài của mỗi từ sử dụng hàm Len [].Nếu độ dài là chẵn, sau đó in từ.First split the given string using the split[] function and then iterate the words of a string using for loop. Calculate the length of each word using the len[] function. If the length is even, then print the word.

    Bài Viết Liên Quan

    Chủ Đề