def perfectSquares1(L):
    # Dealing with an empty list
    if len(L) == 0:
        return L
    
    m = max(L)
    # Dealing with a list with all negative numbers
    if m < 0:
        return []

    squaresList = squares(int(math.sqrt(m))) # make the list of squares
    answerList = []                          # initialize a new list

    # Iterate through the given list and check if current element exists
    # in the list of squares; if so add it to answer list
    for i in L:                     
        if i in squaresList:
            answerList.append(i)            
    return answerList
