Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d8a422

Browse files
Strings
1 parent 35f51d7 commit 3d8a422

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ You can implement these notes in your own favourite programming language.
3737
- [x] [Stack](Stack-and-Queue/stack.py)
3838
- [x] [Queue](Stack-and-Queue/queue.py)
3939
- [x] [Strings](Strings)
40+
- [x] [Strings](Strings/Strings.ipynb)
4041
- [x] [KMP (Knuth Morris Pratt) Pattern Searching](Strings/KMP.py)
4142
- [x] [Trees](Trees)
4243
- [x] [Binary Search Tree](Trees/binarysearchtree.py)

‎Strings/Strings.ipynb

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"False\n",
13+
"True\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"#T:O(N)\n",
19+
"def ispalindrome(s):\n",
20+
" return s==s[::-1]\n",
21+
"s1= \"mike\"\n",
22+
"s2= \"level\" \n",
23+
"print(ispalindrome(s1))\n",
24+
"print(ispalindrome(s2))"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": 2,
30+
"metadata": {},
31+
"outputs": [
32+
{
33+
"name": "stdout",
34+
"output_type": "stream",
35+
"text": [
36+
"True\n"
37+
]
38+
}
39+
],
40+
"source": [
41+
"#T:O(NLOGN)\n",
42+
"def isanagram(s1,s2):\n",
43+
" return sorted(s1)==sorted(s2)\n",
44+
"\n",
45+
"print(isanagram(\"LISTEN\",\"SILENT\"))"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": 3,
51+
"metadata": {},
52+
"outputs": [
53+
{
54+
"name": "stdout",
55+
"output_type": "stream",
56+
"text": [
57+
"True\n"
58+
]
59+
}
60+
],
61+
"source": [
62+
"#T:O(N)\n",
63+
"from collections import Counter\n",
64+
"def isanagram(s1,s2):\n",
65+
" return Counter(s1)==Counter(s2) #compairing the freuency of each character\n",
66+
"\n",
67+
"print(isanagram(\"LISTEN\",\"SILENT\")) "
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"metadata": {},
74+
"outputs": [],
75+
"source": [
76+
"#Sort by len algorithm\n"
77+
]
78+
}
79+
],
80+
"metadata": {
81+
"kernelspec": {
82+
"display_name": "Python 3.9.7 64-bit",
83+
"language": "python",
84+
"name": "python3"
85+
},
86+
"language_info": {
87+
"codemirror_mode": {
88+
"name": "ipython",
89+
"version": 3
90+
},
91+
"file_extension": ".py",
92+
"mimetype": "text/x-python",
93+
"name": "python",
94+
"nbconvert_exporter": "python",
95+
"pygments_lexer": "ipython3",
96+
"version": "3.9.7"
97+
},
98+
"orig_nbformat": 4,
99+
"vscode": {
100+
"interpreter": {
101+
"hash": "0d591c6e422414675974e227c13f5382000c440fedd3c5006ef2be5d887f0ba7"
102+
}
103+
}
104+
},
105+
"nbformat": 4,
106+
"nbformat_minor": 2
107+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /