Skip to content

Instantly share code, notes, and snippets.

@ilkermanap
Created March 19, 2025 17:08
Show Gist options
  • Save ilkermanap/8dbd1b6d8cc56e5a3bd255ba8c5aa016 to your computer and use it in GitHub Desktop.
Save ilkermanap/8dbd1b6d8cc56e5a3bd255ba8c5aa016 to your computer and use it in GitHub Desktop.
leetcode find repeating numbers
# Tekrarlayan sayiyi bul. len(nums) + 1 boyunda dizi kullan,
# yeni dizi kullanma. sadece dizinin sonundaki bos yeri kullanarak coz
nums1 = [1,2,6,4,5,3,5]
nums2 = [1,3,4,2,2]
nums3 = [3,1,3,4,2]
nums4 = [3,1,2,1]
def repeating(dizi):
i = 0
dizi = dizi +[0]
# 3,1,2,1,0
print(dizi)
for sayi in dizi[:-1]:
dizi[-1] = sayi
3,1,2,1,3
i += 1
for yenisayi in dizi[i:-1]:
if yenisayi == dizi[-1]:
return yenisayi
if __name__ == "__main__":
print(repeating(nums1))
print(repeating(nums2))
print(repeating(nums3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment