We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3182510 commit 5a53fbbCopy full SHA for 5a53fbb
Not Equal Pairs.py
@@ -39,24 +39,24 @@ def findPair(arr):
39
for i in range(1, len(arr)):
40
if arr[i] != temp:
41
pairs += 1
42
- arr.pop(0)
43
- arr.pop(i - 1)
+ arr[0], arr[i - 1] = arr[-1], arr[-2]
+ arr.pop()
44
45
return
46
return True
47
48
+
49
n = int(input())
50
arr = [int(x) for x in input().split(" ")]
-n = len(arr)
51
52
pairs = 0
53
54
while len(arr) > 1:
55
if findPair(arr):
56
break
-if len(arr) > 1:
57
58
+if len(arr) > 1:
59
if arr.count(arr[0]) <= n - len(arr):
60
pairs += arr.count(arr[0]) // 2
61
-
62
print(pairs)
0 commit comments