Well I'm stucked at "1431. Kids With the Greatest Number of Candies". I was reading that each test case should run, so I was working with a lot of self to be sure that it will work. My result is always 5 times "True" in the leetcode editor, but in my Visual Studio Code I get the right results for every test case.
I was reading this and I thought I checked for everything, but it must be something else.
Well here's my code. I'm still learing Python, so my code is a bit long.
'''
class Solution(object):
def kidsWithCandies(self, candies, extraCandies):
self.newcandies = 0
self.extraCandiesfori = []
self.data = []
self.collect = 0
self.check = ""
# Zu den aktuellen Candies die extra Candies dazu zählen
self.i = 0
for i in range(len(candies)):
self.newcandies= candies[i] + extraCandies
self.extraCandiesfori.append(self.newcandies)
# Mit dem extra Candie prüfen ob er nun mehr als die anderen hat, wenn ja -> True, wenn nein -> False
self.i = 0
for i in range(len(candies)):
self.collect = 0
self.j = 0
for j in range(len(self.extraCandiesfori)):
if self.extraCandiesfori[i] >= candies[j]:
self.collect += 1
if self.collect == len(self.extraCandiesfori):
check = "True"
else:
check = "False"
self.data.append(check)
return self.datasol = Solution()
candies = [2,3,5,1,3]
extraCandies = 3
print(sol.kidsWithCandies(candies, extraCandies))
candies = [4,2,1,1,2]
extraCandies = 1
print(sol.kidsWithCandies(candies, extraCandies))
candies = [12, 1, 12]
extraCandies = 10
print(sol.kidsWithCandies(candies, extraCandies))
'''
Any suggestions?
Thank you