ladderz/notebooks/rust/dsa.ipynb
2024-03-05 15:55:21 -05:00

111 lines
2.2 KiB
Text

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ladderz dsa usage\n",
"\n",
"Here are some examples of using the `dsa` (data structures and algorithms) module from `ladderz`.\n",
"\n",
"> This notebook uses [evcxr](https://github.com/evcxr/evcxr) for a Rust Jupyter Kernel. See [the evcxr_jupyter README.md](https://github.com/evcxr/evcxr/blob/main/evcxr_jupyter/README.md) for more info on how to run this notebook on your machine."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "rust"
}
},
"outputs": [],
"source": [
"// Comment the next line and uncomment the subsequent line if running notebook from source\n",
":dep ladderz = { git = \"https://github.com/rzmk/ladderz\", branch = \"main\" }\n",
"// :dep ladderz = { path = \"../../ladderz\" }\n",
"\n",
"use ladderz::dsa;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 217. Contains Duplicate"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "rust"
}
},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dsa::contains_duplicate(vec![1, 3, 4, 2, 4])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 242. Valid Anagram"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"vscode": {
"languageId": "rust"
}
},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dsa::is_anagram(\"marc\".to_owned(), \"cram\".to_owned())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Rust",
"language": "rust",
"name": "rust"
},
"language_info": {
"codemirror_mode": "rust",
"file_extension": ".rs",
"mimetype": "text/rust",
"name": "Rust",
"pygment_lexer": "rust",
"version": ""
}
},
"nbformat": 4,
"nbformat_minor": 2
}