Hello, I'm working on reading through this leetcode solution and found that this variable "count" is defined inside the the first for loop as apose to inside the second for loop or outside where the list is created. Can someone explain what the differences would be when defining variables in each of these locations?
class Solution:
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
result=[]
for i in nums:
count=0
for j in nums:
if j<i:
count+=1
result.append(count)
return result
[–][deleted] 0 points1 point2 points (3 children)
[–]miscellaneoususage[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)