124 lines
2.1 KiB
Plaintext
124 lines
2.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "32e3594e",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"2\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"gifts = [25,64,9,4,100]\n",
|
|
"k = 4\n",
|
|
"\n",
|
|
"gift_s = sorted(gifts, inv)\n",
|
|
"\n",
|
|
"for i \n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "903924a0",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'abc'"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"words = [\"alice\",\"bob\",\"charlie\"]\n",
|
|
"\n",
|
|
"s = \"\".join(i[:1] for i in words)\n",
|
|
"s"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "63d7c061",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"s = \"l|*e*et|c**o|*de|\"\n",
|
|
"\n",
|
|
"is_count = False\n",
|
|
"n = 0\n",
|
|
"for i in s:\n",
|
|
" if i == '|' and is_count == False:\n",
|
|
" is_count = True\n",
|
|
" else:\n",
|
|
" is_count = False\n",
|
|
"\n",
|
|
" if i == '*' and is_count:\n",
|
|
" n += 1\n",
|
|
"\n",
|
|
"\n",
|
|
"print(n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5dcedb17",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'a'"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "LeetCode_tasks",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.13.5"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|