[Python] I don't know what is wrong with my solution for leet code problem-148 (Sort List)...

Discussão em 'Python' iniciado por Stack, Março 17, 2025.

  1. Stack

    Stack Membro Participativo

    class Solution(object):
    def sortList(self, head):
    """
    :type head: Optional[ListNode]
    :rtype: Optional[ListNode]
    """
    def sort(l):
    n=len(l)
    for i in range(n):
    for j in range(0,n-i-1):
    if l[j]>l[j+1]:
    l[j],l[j+1]=l[j+1],l[j]
    return l


    I tried to use bubble sorting for the solution. It worked on my python editor but somehow not working in leet code website.

    Continue reading...

Compartilhe esta Página