Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/components/ui/DailyDSAEmbed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const DailyDSAEmbed = ({ mobile = false, theme = "light" }) => {
const wrapperClasses = mobile
? "block md:hidden w-full"
: "max-w-full hidden md:block";
const height = mobile ? 200 : 280;
const height = mobile ? 350 : 350;

return (
<div className={wrapperClasses}>
Expand Down
30 changes: 30 additions & 0 deletions app/components/ui/NewsletterEmbed.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

const NewsletterEmbed = ({ mobile = false, theme = "light" }) => {
const pageUrl =
typeof window !== "undefined"
? encodeURIComponent(window.location.href)
: "";
const src = `https://scaleengineer.com/embed/subscribe?theme=${theme}&utm_campaign=dsa_visualizer&utm_source=${pageUrl}`;
const wrapperClasses = mobile
? "block md:hidden w-full"
: "max-w-full hidden md:block";
const height = mobile ? 340 : 360;

return (
<div className={wrapperClasses}>
<div className="max-w-full mb-4">
<iframe
src={src}
width="100%"
height={height}
className="border border-black border-dashed rounded-none overflow-hidden"
title="Newsletter Subscribe"
loading="lazy"
></iframe>
</div>
</div>
);
};

export default NewsletterEmbed;
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/comparison/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Comparing two linked lists involves checking whether both lists contain the same sequence of values in the same order.`,
`This is typically done using a pointer approach where we traverse both lists simultaneously and compare values at each corresponding node.`
Expand Down Expand Up @@ -29,8 +53,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -83,6 +110,7 @@ const content = () => {
</ul>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/deletion/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Linked List deletion involves removing nodes from the linked data structure at various positions. Unlike arrays, linked lists allow efficient deletion at any point without requiring shifting of remaining elements.`,
`Deletion is a fundamental operation that enables dynamic modification of the list. The efficiency varies based on deletion position, from O(1) for head to O(n) for arbitrary positions or tail (without tail pointer).`,
Expand Down Expand Up @@ -192,8 +216,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview Section */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -398,6 +425,7 @@ const content = () => {
</div>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/insertion/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Linked List insertion involves adding new nodes to the linked data structure at various positions. Unlike arrays, linked lists allow efficient insertion at any point without reallocation or shifting of existing elements.`,
`Insertion is a fundamental operation that enables dynamic growth of the list. The efficiency varies based on insertion position, from O(1) for head/tail (with tail pointer) to O(n) for arbitrary positions.`,
Expand Down Expand Up @@ -142,8 +166,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview Section */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -345,6 +372,7 @@ const content = () => {
</div>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/merge/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Merging two linked lists involves combining the nodes of both lists into one sorted list. This is typically done using a two-pointer approach where we repeatedly compare the heads of both lists and append the smaller node to the result.`,
`This operation is especially useful when both input lists are already sorted. The result is also a sorted list without requiring additional sorting operations.`
Expand Down Expand Up @@ -30,8 +54,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -84,6 +111,7 @@ const content = () => {
</ul>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/reverse/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Reversing a linked list involves changing the direction of the pointers so that the last node becomes the head and the head becomes the last node.`,
`This operation is fundamental in many algorithms and helps in scenarios where you need to process the list in reverse order without using extra space.`
Expand Down Expand Up @@ -30,8 +54,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -84,6 +111,7 @@ const content = () => {
</ul>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
32 changes: 30 additions & 2 deletions app/visualizer/linkedList/operations/traversal/content.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
"use client";
import { useEffect, useState } from "react";
import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";

const content = () => {

const [theme, setTheme] = useState("light");

useEffect(() => {
const updateTheme = () => {
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);
};

updateTheme();

window.addEventListener("storage", updateTheme);
window.addEventListener("themeChange", updateTheme);

return () => {
window.removeEventListener("storage", updateTheme);
window.removeEventListener("themeChange", updateTheme);
};
}, []);

const overview = [
`Linked List traversal involves visiting each node in the list exactly once, starting from the head and moving through the next pointers until the end is reached.`,
`Traversal is essential for operations like searching, displaying, or processing each element of the list. It ensures that all elements are accessed in sequence.`,
Expand Down Expand Up @@ -81,8 +105,11 @@ const content = () => {
];

return (
<main className="max-w-4xl mx-auto">
<article className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-12 md:gap-4">
<div className="md:col-span-3">
<NewsletterEmbed mobile={false} theme={theme} />
</div>
<article className="md:col-span-9 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
{/* Overview Section */}
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
Expand Down Expand Up @@ -254,6 +281,7 @@ const content = () => {
</div>
</section>
</article>
<NewsletterEmbed mobile theme={theme} />
</main>
);
};
Expand Down
2 changes: 1 addition & 1 deletion app/visualizer/linkedList/types/circular/animation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const CircularLinkedListVisualizer = () => {
<h1 className="text-4xl md:text-4xl mt-6 ml-10 font-bold text-left text-gray-900 dark:text-white mb-0">
<span className="text-black dark:text-white">Circular Linked List</span>
</h1>
<div className="bg-black border border-none dark:bg-gray-600 w-100 h-[2px] rounded-xl mt-2 mb-5"></div>
<div className="bg-black border border-none dark:bg-gray-600 w-full h-[2px] rounded-xl mt-2 mb-5"></div>
<Content />
<p className="text-lg text-center text-gray-600 dark:text-gray-400 mb-8">
Visualize Circular Linked List Operations
Expand Down
Loading
Loading