Trying to code up naive solution, keep getting "Unknown Error"


  • 0
    S

    It keeps returning unknown error when I try running the code. It works fine on my computer which runs python 2.7.

    Here's the code

    class Solution(object):
        def dailyTemperatures(self, temperatures):
            """
            :type temperatures: List[int]
            :rtype: List[int]
            """
            
            # naive solution to stop on every element and find the next hotter temp in the list, worst case is it would run n^2
            
            final_list = [0] * len(temperatures)
            
            for i in range(0, len(temperatures), 1):
                for j in range(i+1, len(temperatures), 1):
                    if temperatures[j] > temperatures[i]:
                        final_list[i] = j - i
                        break
                        
            return final_list
    

    I'm not sure what I'm doing wrong, this is my first time using leetcode.


  • 0
    S

    okay for some reason this works in the code playground but not here...


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.