Skip to content

Commit 0f112ab

Browse files
committed
solved medium leetcode
1 parent de47628 commit 0f112ab

File tree

1 file changed

+61
-3
lines changed

1 file changed

+61
-3
lines changed

leetcode_kuro_RnD.ipynb

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8722,16 +8722,74 @@
87228722
},
87238723
{
87248724
"cell_type": "code",
8725-
"execution_count": null,
8725+
"execution_count": 34,
87268726
"metadata": {},
8727-
"outputs": [],
8727+
"outputs": [
8728+
{
8729+
"name": "stdout",
8730+
"output_type": "stream",
8731+
"text": [
8732+
"(3, 2)\n",
8733+
"(2, 1)\n",
8734+
"[3]\n"
8735+
]
8736+
}
8737+
],
87288738
"source": [
87298739
"# https://leetcode.com/problems/majority-element-ii/\n",
87308740
"\n",
87318741
"import collections\n",
8742+
"from typing import Counter\n",
87328743
"\n",
87338744
"nums = [3,2,3]\n",
8734-
"\n"
8745+
"\n",
8746+
"most_common_dict = Counter(nums).most_common()\n",
8747+
"common_vals = []\n",
8748+
"\n",
8749+
"for val in most_common_dict: \n",
8750+
" print(val)\n",
8751+
" if val[1] > len(nums)//3 : \n",
8752+
" common_vals.append(val[0])\n",
8753+
" else:\n",
8754+
" continue\n",
8755+
"\n",
8756+
"print(common_vals)"
8757+
]
8758+
},
8759+
{
8760+
"cell_type": "code",
8761+
"execution_count": null,
8762+
"metadata": {},
8763+
"outputs": [],
8764+
"source": [
8765+
"# https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/"
8766+
]
8767+
},
8768+
{
8769+
"cell_type": "code",
8770+
"execution_count": 29,
8771+
"metadata": {},
8772+
"outputs": [
8773+
{
8774+
"name": "stdout",
8775+
"output_type": "stream",
8776+
"text": [
8777+
"[1, 2, 4]\n"
8778+
]
8779+
}
8780+
],
8781+
"source": [
8782+
"# dailuy challange : 14 oct 2022 : https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/\n",
8783+
"\n",
8784+
"head = [1,3,4,7,1,2,6]\n",
8785+
"head = [2,1]\n",
8786+
"head = [1,2,3,4]\n",
8787+
"\n",
8788+
"mid = len(head)//2\n",
8789+
"\n",
8790+
"head.pop(mid)\n",
8791+
"\n",
8792+
"print(head)"
87358793
]
87368794
},
87378795
{

0 commit comments

Comments
 (0)