summaryrefslogtreecommitdiff
path: root/progs/a255.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a255.py')
-rw-r--r--progs/a255.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/progs/a255.py b/progs/a255.py
new file mode 100644
index 0000000..5b44c24
--- /dev/null
+++ b/progs/a255.py
@@ -0,0 +1,12 @@
+def find_Min_Swaps(arr,n) :
+ noOfZeroes = [0] * n
+ count = 0
+ noOfZeroes[n - 1] = 1 - arr[n - 1]
+ for i in range(n-2,-1,-1) :
+ noOfZeroes[i] = noOfZeroes[i + 1]
+ if (arr[i] == 0) :
+ noOfZeroes[i] = noOfZeroes[i] + 1
+ for i in range(0,n) :
+ if (arr[i] == 1) :
+ count = count + noOfZeroes[i]
+ return count \ No newline at end of file