Skip to content

Commit f8f43d7

Browse files
committed
solved 1551 medium
1 parent c88cf19 commit f8f43d7

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

leetcode_kuro_RnD.ipynb

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8884,10 +8884,43 @@
88848884
},
88858885
{
88868886
"cell_type": "code",
8887-
"execution_count": null,
8887+
"execution_count": 35,
88888888
"metadata": {},
8889-
"outputs": [],
8890-
"source": []
8889+
"outputs": [
8890+
{
8891+
"name": "stdout",
8892+
"output_type": "stream",
8893+
"text": [
8894+
"[1, 3, 5, 7, 9, 11]\n",
8895+
"6\n",
8896+
"9\n"
8897+
]
8898+
}
8899+
],
8900+
"source": [
8901+
"# https://leetcode.com/problems/minimum-operations-to-make-array-equal/\n",
8902+
"\n",
8903+
"# arr[i] = (2 * i) + 1\n",
8904+
"\n",
8905+
"n = 6 \n",
8906+
"\n",
8907+
"arr = [''] * n\n",
8908+
"\n",
8909+
"for i in range(n):\n",
8910+
" arr[i] = (2 * i) + 1\n",
8911+
"\n",
8912+
"print(arr)\n",
8913+
"\n",
8914+
"target = sum(arr)//n \n",
8915+
"print(target)\n",
8916+
"\n",
8917+
"oper_cnt = set()\n",
8918+
"\n",
8919+
"for i, val in enumerate(arr): \n",
8920+
" oper_cnt.add(abs(val - target))\n",
8921+
"\n",
8922+
"print(sum(oper_cnt))"
8923+
]
88918924
},
88928925
{
88938926
"cell_type": "code",

0 commit comments

Comments
 (0)