Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,055 changes: 937 additions & 118 deletions Datastructures + Algorithms/0_Problem_Solving_Patterns.ipynb

Large diffs are not rendered by default.

Empty file.
570 changes: 570 additions & 0 deletions Datastructures + Algorithms/1a_strings.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,15 @@
"# Methods / Operations"
]
},
{
"cell_type": "markdown",
"id": "b682a1d6",
"metadata": {},
"source": [
"- Access an element from the array"
]
},
{
"cell_type": "markdown",
"id": "daea8755",
"metadata": {},
"source": [
"## .add(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d7834953",
"metadata": {},
"outputs": [],
"source": [
"## .add(x)\n",
"\n",
"# Add single element - O(1)\n",
"fruits = {'apple', 'banana', 'cherry'}\n",
"fruits.add('orange')\n",
Expand All @@ -97,21 +83,15 @@
"print(fruits)"
]
},
{
"cell_type": "markdown",
"id": "88b14760",
"metadata": {},
"source": [
"## .update(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42fcf8cf",
"metadata": {},
"outputs": [],
"source": [
"## .update(x)\n",
"\n",
"# Add multiple elements - O(k)\n",
"fruits.update(['mango', 'grape'])\n",
"print(fruits)\n",
Expand All @@ -121,21 +101,15 @@
"print(fruits)"
]
},
{
"cell_type": "markdown",
"id": "beb13645",
"metadata": {},
"source": [
"## .remove(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c87f3d47",
"metadata": {},
"outputs": [],
"source": [
"## .remove(x)\n",
"\n",
"\"\"\"\n",
"### .remove(x)\n",
"\n",
Expand All @@ -151,21 +125,15 @@
"# fruits.remove('grape') # KeyError: 'grape'"
]
},
{
"cell_type": "markdown",
"id": "dea6410d",
"metadata": {},
"source": [
"## .discard(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "26dd28ed",
"metadata": {},
"outputs": [],
"source": [
"## .discard(x)\n",
"\n",
"\"\"\"\n",
"### .discard(x)\n",
"\n",
Expand All @@ -182,21 +150,15 @@
"print(fruits) # {'apple', 'cherry'}"
]
},
{
"cell_type": "markdown",
"id": "5f42fda1",
"metadata": {},
"source": [
"## .pop()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "639bc10d",
"metadata": {},
"outputs": [],
"source": [
"## .pop()\n",
"\n",
"\"\"\"\n",
"### .pop()\n",
"\n",
Expand All @@ -214,17 +176,9 @@
"# fruits.pop() # KeyError: 'pop from an empty set'"
]
},
{
"cell_type": "markdown",
"id": "bc3fee5e",
"metadata": {},
"source": [
"## .clear()"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "9b570bce",
"metadata": {},
"outputs": [
Expand All @@ -238,6 +192,8 @@
}
],
"source": [
"## .clear()\n",
"\n",
"\"\"\"\n",
"### .clear()\n",
"\n",
Expand All @@ -251,21 +207,14 @@
"print(len(fruits)) # 0"
]
},
{
"cell_type": "markdown",
"id": "994e0c62",
"metadata": {},
"source": [
"## in / not in"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7442d5bf",
"metadata": {},
"outputs": [],
"source": [
"## in / not in\n",
"\"\"\"\n",
"### in / not in\n",
"\n",
Expand All @@ -283,21 +232,14 @@
"print('apple' in fruits_list) # True, but O(n)"
]
},
{
"cell_type": "markdown",
"id": "5863a494",
"metadata": {},
"source": [
"## .union()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46887656",
"metadata": {},
"outputs": [],
"source": [
"## .union()\n",
"\"\"\"\n",
"### .union() / |\n",
"\n",
Expand All @@ -321,21 +263,14 @@
"print(union3) # {1, 2, 3, 4, 5, 6}"
]
},
{
"cell_type": "markdown",
"id": "448d41d1",
"metadata": {},
"source": [
"## .intersection()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38312cb6",
"metadata": {},
"outputs": [],
"source": [
"## .intersection()\n",
"\"\"\"\n",
"### .intersection() / &\n",
"\n",
Expand All @@ -359,21 +294,14 @@
"print(intersection3) # {4}"
]
},
{
"cell_type": "markdown",
"id": "0de58e7c",
"metadata": {},
"source": [
"## .difference()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23930ef8",
"metadata": {},
"outputs": [],
"source": [
"## .difference()\n",
"\"\"\"\n",
"### .difference() / -\n",
"\n",
Expand Down Expand Up @@ -401,21 +329,14 @@
"print(diff4) # {1}"
]
},
{
"cell_type": "markdown",
"id": "878fb1a9",
"metadata": {},
"source": [
"## .symmetric_difference() / ^"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "584dfa75",
"metadata": {},
"outputs": [],
"source": [
"## .symmetric_difference() / ^\n",
"\"\"\"\n",
"### .symmetric_difference() / ^\n",
"\n",
Expand All @@ -437,21 +358,14 @@
"print(set1 ^ set2 == set2 ^ set1) # True"
]
},
{
"cell_type": "markdown",
"id": "2a373278",
"metadata": {},
"source": [
"## .issubset() / <="
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c10c368c",
"metadata": {},
"outputs": [],
"source": [
"## .issubset() / <=\n",
"\"\"\"\n",
"### .issubset() / <=\n",
"\n",
Expand All @@ -473,21 +387,14 @@
"print(set().issubset(set1)) # True"
]
},
{
"cell_type": "markdown",
"id": "1b19f1a8",
"metadata": {},
"source": [
"## .issuperset() / >="
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a6cda23",
"metadata": {},
"outputs": [],
"source": [
"## .issuperset() / >=\n",
"\"\"\"\n",
"### .issuperset() / >=\n",
"\n",
Expand All @@ -508,21 +415,14 @@
"print(set1.issuperset(set())) # True"
]
},
{
"cell_type": "markdown",
"id": "db339c1b",
"metadata": {},
"source": [
"## .isdisjoint()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b768920c",
"metadata": {},
"outputs": [],
"source": [
"## .isdisjoint()\n",
"\"\"\"\n",
"### .isdisjoint()\n",
"\n",
Expand Down
Loading