Find Second Smallest Element in an Array

    0

    0

    CrypticSai-08

    import math
    arr = [10, 13, 17, 11, 34, 21]
    first = math.inf
    second = math.inf
    for i in range(0, len(arr)):
       if arr[i] < first:
         first = arr[i]
    for i in range(0, len(arr)):
       if arr[i] != first and arr[i] < second:
         second = arr[i]
    print(second)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.