Count stable rune fusions
A crafting system fuses two runes into one. Every rune carries a positive integer charge, and a fusion is stable when the product of the two charges is a perfect square, the square of some whole number. Runes at two different positions may fuse even when their charges are equal, and no rune fuses with itself. Charges reach a billion, so the product of two of them lands outside the range where a double counts exactly. Given the charges in catalogue order, return a list where position i holds how many other positions hold a rune that fuses stably with the rune at position i.
fusion_partner_counts(charges: list[int]) → list[int][[2,8,3]]out[1,1,0][[5,5,20]]out[2,2,2][[1,4,9,7]]out[2,2,2,0]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[2,8,3]][1,1,0]not run yetsample[[5,5,20]][2,2,2]not run yetsample[[1,4,9,7]][2,2,2,0]not run yetsample