{"id":11204,"date":"2025-11-24T11:26:00","date_gmt":"2025-11-24T05:56:00","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=11204"},"modified":"2025-11-24T17:13:25","modified_gmt":"2025-11-24T11:43:25","slug":"depth-first-search-dfs","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/depth-first-search-dfs\/","title":{"rendered":"Depth First Search (DFS)"},"content":{"rendered":"\n<!-- PrismJS for Syntax Highlighting -->\n<link href=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/themes\/prism-tomorrow.min.css\" rel=\"stylesheet\">\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/prism.min.js\"><\/script>\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/plugins\/autoloader\/prism-autoloader.min.js\"><\/script>\n\n<style>\n.wp_blog_theme {\n  --primary: #E58C32;\n  --secondary: #030302;\n  --light-bg: #fef9f4;\n  --text-dark: #2d2d2d;\n  --tab-radius: 12px;\n  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n  --code-bg: #001f3f;\n  --code-text: #d4f1ff;\n}\n\n.wp_blog_container {\n  font-family: 'Segoe UI', sans-serif;\n  background: var(--light-bg);\n  margin: 0;\n  padding: 0;\n  color: var(--text-dark);\n}\n\n\/* Heading *\/\n.wp_blog_main-heading {\n  text-align: center;\n  font-size: 2.4rem;\n  color: var(--primary);\n  margin-top: 2.5rem;\n  font-weight: bold;\n}\n\n\/* Explanation Card *\/\n.wp_blog_explanation,\n.wp_blog_code-tabs-container {\n  max-width: 940px;\n  margin: 2rem auto;\n  padding: 2rem;\n  background: white;\n  border-radius: var(--tab-radius);\n  box-shadow: var(--shadow);\n}\n\n\/* Text and Visuals *\/\n.wp_blog_explanation h2 {\n  font-size: 1.4rem;\n  color: var(--primary);\n  margin-bottom: 0.5rem;\n}\n\n.wp_blog_explanation p,\n.wp_blog_explanation li {\n  font-size: 1.05rem;\n  line-height: 1.7;\n  margin: 0.5rem 0;\n}\n\n.wp_blog_explanation code {\n  background: #fef9f4;   \/* light bg instead of dark blue *\/\n  color: #E58C32;        \/* brand orange *\/\n  padding: 3px 6px;\n  border-radius: 4px;\n  font-family: 'Courier New', monospace;\n  font-weight: 600;      \/* optional, makes it pop *\/\n}\n\n.wp_blog_explanation img {\n  max-width: 100%;\n  border-radius: var(--tab-radius);\n  margin-top: 1rem;\n  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);\n}\n\n\/* Tab Buttons *\/\n.wp_blog_code-tabs-header {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 0.5rem;\n  margin-bottom: 1rem;\n}\n\n.wp_blog_code-tab-button {\n  padding: 0.6rem 1.2rem;\n  border: 1px solid var(--primary);\n  background: white;\n  color: var(--primary);\n  border-radius: 50px;\n  font-weight: 600;\n  cursor: pointer;\n  transition: all 0.3s ease;\n}\n\n.wp_blog_code-tab-button:hover {\n  background: var(--secondary);\n}\n\n.wp_blog_code-tab-button.active {\n  background: var(--primary);\n  color: white;\n}\n\n\/* Code Content *\/\n.wp_blog_code-tab-content {\n  display: none;\n  background: var(--code-bg);\n  border-radius: var(--tab-radius);\n}\n\n.wp_blog_code-tab-content.active {\n  display: block;\n}\n\n.wp_blog_code-tab-content pre {\n  margin: 0;\n  padding: 1.5rem;\n  font-size: 1rem;\n  overflow-x: auto;\n  background: var(--code-bg);\n  border-radius: var(--tab-radius);\n  color: var(--code-text);\n}\n\n\/* Dark mode variables *\/\n.wp_blog_theme.dark-mode {\n  --light-bg: #121212;\n  --text-dark: #f5f5f5;\n  --shadow: 0 4px 12px rgba(255, 255, 255, 0.08);\n  --code-bg: #1e1e1e;\n  --code-text: #c5f0ff;\n}\n\n.wp_blog_theme.dark-mode .wp_blog_explanation {\n  background: #1e1e1e;\n}\n\n\/* Dark mode code highlight *\/\n.wp_blog_theme.dark-mode .wp_blog_explanation code {\n  background: #333;\n  color: #ffd27f;\n}\n\n.wp_blog_theme {\n  position: relative; \/* makes it the reference for absolute children *\/\n}\n\n.wp_blog_toggle-btn {\n  position: absolute;\n  top: 1rem;\n  right: 1rem;\n  z-index: 9999;\n  padding: 0.5rem 0.8rem;\n  border-radius: 10%;\n  background: var(--primary);\n  color: white;\n  font-weight: bold;\n  cursor: pointer;\n  border: none;\n  box-shadow: var(--shadow);\n  transition: background 0.3s, transform 0.2s;\n}\n\n.wp_blog_toggle-btn:hover {\n  background: #cc772e;\n}\n\n.wp_blog_theme.dark-mode .wp_blog_code-tabs-container {\n  background: #1e1e1e;\n}\n<\/style>\n\n<div class=\"wp_blog_container wp_blog_theme\">\n  <button id=\"blogNotesThemeToggle\" class=\"wp_blog_toggle-btn\">\ud83c\udf19<\/button>\n  <h1 class=\"wp_blog_main-heading\"><\/h1>\n\n  <div class=\"wp_blog_explanation\">\n    <h2>Depth First Search (DFS)<\/h2>\n    <h2>Example: 1<\/h2>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/1.png\" alt=\"\">\n    <p><strong>DFS: <\/strong><code>[0, 1, 3, 2, 4]<\/code><\/p>\n\n    <h2>Example: 2<\/h2>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/2.png\" alt=\"\">\n    <p><strong>DFS: <\/strong><code>[1, 4, 5, 6, 7, 3, 9, 8, 2]<\/code><\/p>\n    <p>Another Possible Solution: <\/p>\n    <p><strong>DFS: <\/strong>[1, 2, 3, 4, 5, 6, 7, 8, 9]<\/p>\n    \n    <h2>Real-World Example<\/h2>\n    <!-- Chandigarh -->\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/3.png\" alt=\"\">\n    <p><strong>DFS: <\/strong><code>[Mussoorie, Dehradun, Delhi, Agra, Jaipur, Chandigarh]<\/code><\/p>\n\n    <p><strong>We implement Depth-First Search (DFS) using a <code>Stack<\/code> data structure<\/strong><\/p>\n   \n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/1.png\" alt=\"\">\n    <ul>\n        <li>Push the start node into the stack.<\/li>\n        <li>Create a visited set to track visited nodes.<\/li>\n        <li>While the stack is not empty:\n            <ul>\n                <li>Pop the top node.<\/li>\n                <li>If not visited \u2192 mark visited and process it.<\/li>\n                <li>Push all unvisited neighbors into the stack.<\/li>\n            <\/ul>\n        <\/li>\n        <li>Repeat until the stack becomes empty.<\/li>\n    <\/ul>\n    <h2>Problem Statement:<\/h2>\n    <p>\n       Given a reference of a node in a connected undirected graph.\n    <\/p>\n    <p>\n        Return a deep copy (clone) of the graph.\n    <\/p>\n    <p>\n        Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors.\n    <\/p>\n    <pre>\n        class Node {\n            public int val;\n            public List<Node> neighbors;\n        }\n    <\/pre>\n\n    <p><strong>Test case format:<\/strong><\/p>\n    <p>\n        For simplicity, each node&#8217;s value is the same as the node&#8217;s index (1-indexed). For example, the first node with <code>val == 1<\/code>, the second node with val == 2, and so on. The graph is represented in the test case using an adjacency list.\n    <\/p>\n\n    <p>\n        <strong>An adjacency list<\/strong> is a collection of unordered <strong>lists<\/strong> used to represent a finite graph. Each list describes the set of neighbors of a node in the graph.\n    <\/p>\n\n    <p>\n        The given node will always be the first node with <code>val = 1<\/code>. You must return the <strong>copy of the given node<\/strong> as a reference to the cloned graph.\n    <\/p>\n\n    <h3>Example 1:<\/h3>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/img_1.png\" alt=\"\">\n    <p><strong>Input: <\/strong>adjList = [[2,4],[1,3],[2,4],[1,3]]<\/p>\n    <p><strong>Output: <\/strong>[[2,4],[1,3],[2,4],[1,3]]<\/p>\n    <p><strong>Explanation: <\/strong>There are 4 nodes in the graph.\n        1st node (val = 1)&#8217;s neighbors are 2nd node (val = 2) and 4th node (val = 4).\n        2nd node (val = 2)&#8217;s neighbors are 1st node (val = 1) and 3rd node (val = 3).\n        3rd node (val = 3)&#8217;s neighbors are 2nd node (val = 2) and 4th node (val = 4).\n        4th node (val = 4)&#8217;s neighbors are 1st node (val = 1) and 3rd node (val = 3).<\/p>\n\n    <h3>Example 2:<\/h3>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/img_2.png\" alt=\"\">\n    <p><strong>Input: <\/strong>adjList = [[]]<\/p>\n    <p><strong>Output: <\/strong>[[]]<\/p>\n    <p><strong>Explanation: <\/strong>Note that the input contains one empty list. The graph consists of only one node with val = 1 and it does not have any neighbors.<\/p>\n\n\n    <h3>Example 3:<\/h3>\n    <p><strong>Input: <\/strong>adjList = []<\/p>\n    <p><strong>Output: <\/strong>[]<\/p>\n    <p><strong>Explanation: <\/strong>This an empty graph, it does not have any nodes.<\/p>\n\n    <h3>Constraints<\/h3>\n    <ul>\n        <li>The number of nodes in the graph is in the range [0, 100].<\/li>\n        <li><code>1 <= Node.val <= 100<\/code><\/li>\n        <li><code>Node.val<\/code> is unique for each node.<\/li>\n        <li>There are no repeated edges and no self-loops in the graph.<\/li>\n        <li>The Graph is connected and all nodes can be visited starting from the given node.<\/li>\n    <\/ul>\n    \n    <h2>Approach<\/h2>\n    <ul>\n        <li>If the input node is null, return null\n            <ul>\n                <li>Because there is no graph to clone.<\/li>\n            <\/ul>\n        <\/li>\n        <li>Create a stack and push the root node inside it: This stack helps perform DFS.<\/li>\n        <li>Create a map (visited) to store already-cloned nodes:\n            <ul>\n                <li>\u2013 Key: original node<\/li>\n                <li>\u2013 Value: cloned node<\/li>\n                <li>\u2013 Prevents re-cloning the same node again.<\/li>\n            <\/ul>\n        <\/li>\n        <li>Create the cloned version of the root node: Store it in the map.<\/li>\n        <li>Start DFS: while the stack is not empty, Pop a node(<code>curr<\/code>) from the stack.<\/li>\n        <li>Get the cloned node corresponding to curr\n            <ul>\n                <li>\u2013 This is needed to attach cloned neighbors.<\/li>\n            <\/ul>\n        <\/li>\n        <li>Traverse each neighbor <code>n<\/code> of <code>curr<\/code><\/li>\n        <li><strong>If neighbor is not already cloned:<\/strong>\n        <ul>\n            <li>Create its clone.<\/li>\n            <li>Add it to the map.<\/li>\n            <li>Push the neighbor onto the stack (so we explore it later).<\/li>\n        <\/ul>\n        <\/li>\n        <li>Connect the cloned nodes:\n            <ul>\n                <li>Add <code>visited.get(n)<\/code> to cloneCurr.neighbors<\/li>\n            <\/ul>\n        <\/li>\n        <li>After <strong>DFS completes<\/strong>, return the cloned root.<\/li>\n    <\/ul>\n\n<\/div> \n\n    <div class=\"wp_blog_code-tabs-container\">\n        <div class=\"wp_blog_code-tabs-header\">\n            <button class=\"wp_blog_code-tab-button active\" data-lang=\"js\">JavaScript<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"py\">Python<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"java\">Java<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"cpp\">C++<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"c\">C<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"cs\">C#<\/button>\n        <\/div>\n\n        <!-- JavaScript -->\n        <div class=\"wp_blog_code-tab-content active\" data-lang=\"js\">\n            <pre><code class=\"language-javascript\">\nvar cloneGraph = function(root) {\n    if (!root) return null;\n\n    const stack = [root];\n    const visited = new Map();\n    const cloneRoot = new Node(root.val);\n    visited.set(root, cloneRoot);\n\n    while (stack.length) {\n        const curr = stack.shift();\n        const cloneCurr = visited.get(curr);\n\n        for (const n of curr.neighbors) {\n            if (!visited.has(n)) {\n                visited.set(n, new Node(n.val));\n                stack.push(n);\n            }\n            cloneCurr.neighbors.push(visited.get(n));\n        }\n    }\n    return cloneRoot;\n};\n      <\/code><\/pre>\n        <\/div>\n\n        <!-- Python -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"py\">\n            <pre><code class=\"language-python\">\ndef cloneGraph(root: 'Node') -> 'Node':\n    if not root:\n        return None\n\n    stack = [root]\n    visited = {}             # original_node -> cloned_node\n\n    cloneRoot = Node(root.val)\n    visited[root] = cloneRoot\n\n    while stack:\n        curr = stack.pop()   # LIFO: iterative DFS\n        cloneCurr = visited[curr]\n\n        for n in curr.neighbors:\n            if n not in visited:\n                visited[n] = Node(n.val)\n                stack.append(n)\n            cloneCurr.neighbors.append(visited[n])\n\n    return cloneRoot\n            <\/code><\/pre>\n        <\/div>\n\n        <!-- Java -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"java\">\n            <pre><code class=\"language-java\">\nimport java.util.*;\n\nclass Node {\n    public int val;\n    public List<Node> neighbors;\n    public Node() { val = 0; neighbors = new ArrayList<Node>(); }\n    public Node(int _val) { val = _val; neighbors = new ArrayList<Node>(); }\n    public Node(int _val, ArrayList<Node> _neighbors) { val = _val; neighbors = _neighbors; }\n}\n\npublic class Solution {\n    public Node cloneGraph(Node root) {\n        if (root == null) return null;\n\n        Deque<Node> stack = new ArrayDeque<>();\n        Map<Node, Node> visited = new HashMap<>();\n\n        Node cloneRoot = new Node(root.val);\n        visited.put(root, cloneRoot);\n        stack.push(root);\n\n        while (!stack.isEmpty()) {\n            Node curr = stack.pop();           \/\/ LIFO\n            Node cloneCurr = visited.get(curr);\n\n            for (Node n : curr.neighbors) {\n                if (!visited.containsKey(n)) {\n                    visited.put(n, new Node(n.val));\n                    stack.push(n);\n                }\n                cloneCurr.neighbors.add(visited.get(n));\n            }\n        }\n        return cloneRoot;\n    }\n}\n\n     <\/code><\/pre>\n        <\/div>\n\n        <!-- C++ -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"cpp\">\n            <pre><code class=\"language-cpp\">\n#include &lt;vector&gt;\n#include &lt;stack&gt;\n#include &lt;nordered_map&gt;\nusing namespace std;\n\nclass Node {\npublic:\n    int val;\n    vector<Node*> neighbors;\n    Node() : val(0) {}\n    Node(int _val) : val(_val) {}\n    Node(int _val, vector<Node*> _neighbors) : val(_val), neighbors(_neighbors) {}\n};\n\nNode* cloneGraph(Node* root) {\n    if (!root) return nullptr;\n\n    unordered_map<Node*, Node*> visited; \/\/ original -> clone\n    stack<Node*> st;\n\n    Node* cloneRoot = new Node(root->val);\n    visited[root] = cloneRoot;\n    st.push(root);\n\n    while (!st.empty()) {\n        Node* curr = st.top(); st.pop(); \/\/ LIFO\n        Node* cloneCurr = visited[curr];\n\n        for (Node* n : curr->neighbors) {\n            if (visited.find(n) == visited.end()) {\n                visited[n] = new Node(n->val);\n                st.push(n);\n            }\n            cloneCurr->neighbors.push_back(visited[n]);\n        }\n    }\n    return cloneRoot;\n}\n  <\/code><\/pre>\n        <\/div>\n\n        <!-- C -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"c\">\n            <pre><code class=\"language-c\">\n#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\ntypedef struct Node {\n    int val;\n    struct Node** neighbors;\n    int neighborsCount;\n} Node;\n\nNode* createNode(int val) {\n    Node* n = (Node*)malloc(sizeof(Node));\n    n->val = val;\n    n->neighbors = NULL;\n    n->neighborsCount = 0;\n    return n;\n}\n\nvoid addNeighbor(Node* node, Node* neigh) {\n    node->neighbors = realloc(node->neighbors, sizeof(Node*) * (node->neighborsCount + 1));\n    node->neighbors[node->neighborsCount++] = neigh;\n}\n\n\/* visited mapping using parallel arrays origs[i] -> clones[i] *\/\nNode* findClone(Node** origs, Node** clones, int size, Node* key) {\n    for (int i = 0; i < size; ++i) if (origs[i] == key) return clones[i];\n    return NULL;\n}\n\nvoid addMapping(Node*** origsRef, Node*** clonesRef, int* sizeRef, Node* orig, Node* clone) {\n    int size = *sizeRef;\n    *origsRef  = realloc(*origsRef,  (size + 1) * sizeof(Node*));\n    *clonesRef = realloc(*clonesRef, (size + 1) * sizeof(Node*));\n    (*origsRef)[size] = orig;\n    (*clonesRef)[size] = clone;\n    *sizeRef = size + 1;\n}\n\n\/* iterative DFS clone *\/\nNode* cloneGraph(Node* root) {\n    if (!root) return NULL;\n\n    Node** origs = NULL;\n    Node** clones = NULL;\n    int mapSize = 0;\n\n    int stackCap = 64;\n    Node** stack = malloc(sizeof(Node*) * stackCap);\n    int sp = 0; \/\/ stack pointer: push -> stack[sp++] , pop -> stack[--sp]\n\n    Node* cloneRoot = createNode(root->val);\n    addMapping(&origs, &clones, &mapSize, root, cloneRoot);\n\n    \/\/ push root\n    if (sp == stackCap) { stackCap *= 2; stack = realloc(stack, sizeof(Node*) * stackCap); }\n    stack[sp++] = root;\n\n    while (sp > 0) {\n        Node* curr = stack[--sp]; \/\/ pop (LIFO)\n        Node* cloneCurr = findClone(origs, clones, mapSize, curr);\n\n        for (int i = 0; i < curr->neighborsCount; ++i) {\n            Node* neigh = curr->neighbors[i];\n            Node* cloneNeigh = findClone(origs, clones, mapSize, neigh);\n\n            if (!cloneNeigh) {\n                cloneNeigh = createNode(neigh->val);\n                addMapping(&origs, &clones, &mapSize, neigh, cloneNeigh);\n\n                if (sp == stackCap) {\n                    stackCap *= 2;\n                    stack = realloc(stack, sizeof(Node*) * stackCap);\n                }\n                stack[sp++] = neigh; \/\/ push neighbor to stack for DFS\n            }\n            addNeighbor(cloneCurr, cloneNeigh);\n        }\n    }\n\n    free(stack);\n    free(origs);\n    free(clones);\n    return cloneRoot;\n}    <\/code><\/pre>\n        <\/div>\n\n        <!-- C# -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"cs\">\n            <pre><code class=\"language-csharp\">\nusing System.Collections.Generic;\n\npublic class Node {\n    public int val;\n    public IList<Node> neighbors;\n    public Node() { val = 0; neighbors = new List<Node>(); }\n    public Node(int _val) { val = _val; neighbors = new List<Node>(); }\n    public Node(int _val, IList<Node> _neighbors) { val = _val; neighbors = _neighbors; }\n}\n\npublic class Solution {\n    public Node CloneGraph(Node root) {\n        if (root == null) return null;\n\n        var stack = new Stack<Node>();\n        var visited = new Dictionary<Node, Node>();\n\n        var cloneRoot = new Node(root.val);\n        visited[root] = cloneRoot;\n        stack.Push(root);\n\n        while (stack.Count > 0) {\n            var curr = stack.Pop();    \/\/ LIFO\n            var cloneCurr = visited[curr];\n\n            foreach (var n in curr.neighbors) {\n                if (!visited.ContainsKey(n)) {\n                    visited[n] = new Node(n.val);\n                    stack.Push(n);\n                }\n                cloneCurr.neighbors.Add(visited[n]);\n            }\n        }\n        return cloneRoot;\n    }\n}\n\n            <\/code><\/pre>\n        <\/div>\n    <\/div>\n\n<\/div>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n  const buttons = document.querySelectorAll(\".wp_blog_code-tab-button\");\n  const contents = document.querySelectorAll(\".wp_blog_code-tab-content\");\n\n  buttons.forEach((button) => {\n    button.addEventListener(\"click\", () => {\n      const lang = button.getAttribute(\"data-lang\");\n\n      buttons.forEach((btn) => btn.classList.remove(\"active\"));\n      contents.forEach((content) => content.classList.remove(\"active\"));\n\n      button.classList.add(\"active\");\n      document\n        .querySelector(`.wp_blog_code-tab-content[data-lang=\"${lang}\"]`)\n        .classList.add(\"active\");\n    });\n  });\n\n  const themeToggle = document.getElementById(\"blogNotesThemeToggle\");\n  const themeContainer = document.querySelector(\".wp_blog_theme\");\n\n  themeToggle.addEventListener(\"click\", () => {\n    themeContainer.classList.toggle(\"dark-mode\");\n    themeToggle.textContent =\n      themeContainer.classList.contains(\"dark-mode\") ? \"\u2600\ufe0f\" : \"\ud83c\udf19\";\n  });\n});\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udf19 Depth First Search (DFS) Example: 1 DFS: [0, 1, 3, 2, 4] Example: 2 DFS: [1, 4, 5, 6, 7, 3, 9, 8, 2] Another Possible Solution: DFS: [1, 2, 3, 4, 5, 6, 7, 8, 9] Real-World Example DFS: [Mussoorie, Dehradun, Delhi, Agra, Jaipur, Chandigarh] We implement Depth-First Search (DFS) using a Stack<\/p>\n","protected":false},"author":108,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[210,322,260,176,175,211,811,810,174,172,173],"tags":[],"class_list":["post-11204","post","type-post","status-publish","format-standard","category-algorithms","category-algorithms-and-data-structures","category-c-c-plus-plus","category-csharp","category-cplusplus","category-data-structures","category-data-structures-and-algorithms","category-dsa","category-java","category-javascript","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/108"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=11204"}],"version-history":[{"count":2,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11204\/revisions"}],"predecessor-version":[{"id":11209,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11204\/revisions\/11209"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=11204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=11204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=11204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}