Skip to content

Commit 69f950d

Browse files
authored
Merge pull request #5 from iShiBin/master
correct the description of the solution
2 parents f280f4b + 0182723 commit 69f950d

File tree

103 files changed

+10318
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+10318
-495
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 5,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"'HELLO'"
12+
]
13+
},
14+
"execution_count": 5,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
19+
"source": [
20+
"s = 'hello'\n",
21+
"s.upper()"
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": 8,
27+
"metadata": {},
28+
"outputs": [
29+
{
30+
"name": "stdout",
31+
"output_type": "stream",
32+
"text": [
33+
"hi\n"
34+
]
35+
}
36+
],
37+
"source": [
38+
"set1 = set()\n",
39+
"print('hi')"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 6,
45+
"metadata": {},
46+
"outputs": [
47+
{
48+
"data": {
49+
"text/plain": [
50+
"('hello',)"
51+
]
52+
},
53+
"execution_count": 6,
54+
"metadata": {},
55+
"output_type": "execute_result"
56+
}
57+
],
58+
"source": [
59+
"import timeit\n",
60+
"timeit\n",
61+
"singleton = 'hello',\n",
62+
"singleton"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": 8,
68+
"metadata": {},
69+
"outputs": [
70+
{
71+
"name": "stdout",
72+
"output_type": "stream",
73+
"text": [
74+
"<class 'set'>\n",
75+
"{'banana', 'apple', 'orange', 'pear'}\n"
76+
]
77+
}
78+
],
79+
"source": [
80+
"basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n",
81+
"print(type(basket))\n",
82+
"print(basket)"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 15,
88+
"metadata": {},
89+
"outputs": [
90+
{
91+
"name": "stdout",
92+
"output_type": "stream",
93+
"text": [
94+
"{' ', 't', 's', 'i', 'h', 'o', 'e', 'n', 'm', 'g'}\n"
95+
]
96+
}
97+
],
98+
"source": [
99+
"chars = {c for c in 'this is something'}\n",
100+
"print(chars)\n"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": 57,
106+
"metadata": {},
107+
"outputs": [
108+
{
109+
"data": {
110+
"text/plain": [
111+
"True"
112+
]
113+
},
114+
"execution_count": 57,
115+
"metadata": {},
116+
"output_type": "execute_result"
117+
}
118+
],
119+
"source": [
120+
"s = 'A man, a plan, a canal: Panama'\n"
121+
]
122+
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": 66,
126+
"metadata": {},
127+
"outputs": [
128+
{
129+
"ename": "SyntaxError",
130+
"evalue": "'return' outside function (<ipython-input-66-1b6f9701ea18>, line 7)",
131+
"output_type": "error",
132+
"traceback": [
133+
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-66-1b6f9701ea18>\"\u001b[0;36m, line \u001b[0;32m7\u001b[0m\n\u001b[0;31m return False\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m 'return' outside function\n"
134+
]
135+
}
136+
],
137+
"source": [
138+
"s='ab'\n",
139+
"s=s.casefold()\n",
140+
"chars = list(filter(lambda c:c.isalpha(), s))\n",
141+
"low, high=0, len(chars)-1\n",
142+
"while(low<high):\n",
143+
" if chars[low] != chars[high]:\n",
144+
" return False\n",
145+
"return True"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": 82,
151+
"metadata": {},
152+
"outputs": [],
153+
"source": [
154+
"s='ab'\n",
155+
"s = ''.join(filter(lambda c: c.isalnum(), s)).lower()\n"
156+
]
157+
},
158+
{
159+
"cell_type": "code",
160+
"execution_count": null,
161+
"metadata": {},
162+
"outputs": [],
163+
"source": []
164+
}
165+
],
166+
"metadata": {
167+
"kernelspec": {
168+
"display_name": "Python 3",
169+
"language": "python",
170+
"name": "python3"
171+
},
172+
"language_info": {
173+
"codemirror_mode": {
174+
"name": "ipython",
175+
"version": 3
176+
},
177+
"file_extension": ".py",
178+
"mimetype": "text/x-python",
179+
"name": "python",
180+
"nbconvert_exporter": "python",
181+
"pygments_lexer": "ipython3",
182+
"version": "3.6.2"
183+
}
184+
},
185+
"nbformat": 4,
186+
"nbformat_minor": 2
187+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Array\n",
8+
"- Python use reference when slide or extend an array. (Because python uses immutable value for integers and strings)\n",
9+
"## Dynamic Array Implementation\n",
10+
"- The array has an initial size and will expand twice when extending.\n"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"\" \".join()\n",
20+
"reversed()\n",
21+
"s.split()\n",
22+
"len(set(s))"
23+
]
24+
}
25+
],
26+
"metadata": {
27+
"kernelspec": {
28+
"display_name": "Python 3",
29+
"language": "python",
30+
"name": "python3"
31+
},
32+
"language_info": {
33+
"codemirror_mode": {
34+
"name": "ipython",
35+
"version": 3
36+
},
37+
"file_extension": ".py",
38+
"mimetype": "text/x-python",
39+
"name": "python",
40+
"nbconvert_exporter": "python",
41+
"pygments_lexer": "ipython3",
42+
"version": "3.6.2"
43+
}
44+
},
45+
"nbformat": 4,
46+
"nbformat_minor": 2
47+
}

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Python-for-Algorithm-and-Interviews</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

.pydevproject

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
4+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
5+
</pydev_project>

0 commit comments

Comments
 (0)