<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ateev Duggal</title>
    <description>The latest articles on DEV Community by Ateev Duggal (@ateevduggal).</description>
    <link>https://dev.to/ateevduggal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F652453%2F688e4090-7e0f-413d-b97a-fc1248904dcb.jpg</url>
      <title>DEV Community: Ateev Duggal</title>
      <link>https://dev.to/ateevduggal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ateevduggal"/>
    <language>en</language>
    <item>
      <title>OOPS Concepts 101: What Are the Key Concepts You Need to Know?</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Wed, 04 Jun 2025 16:02:04 +0000</pubDate>
      <link>https://dev.to/ateevduggal/oops-concepts-101-what-are-the-key-concepts-you-need-to-know-4e98</link>
      <guid>https://dev.to/ateevduggal/oops-concepts-101-what-are-the-key-concepts-you-need-to-know-4e98</guid>
      <description>&lt;p&gt;Object-Oriented Programming System (OOPS) is a programming paradigm built around the concept of objects — self-contained units that represent real-world entities like users, cars, or bank accounts. While objects are at the heart of OOPS, they are just one part of a broader system of concepts that define how OOP works. Together, these OOPS concepts (like classes, objects, methods, etc) concepts—form the building blocks of modular and efficient software development.&lt;/p&gt;

&lt;p&gt;In this blog, we won’t dive into the four pillars of OOPS — Abstraction, Encapsulation, Polymorphism, and Inheritance — just yet. Instead, we’ll focus on some of the foundational Java concepts that are essential for understanding OOPS.&lt;/p&gt;

&lt;p&gt;These include objects, classes, constructors, methods, access modifiers, etc — the building blocks of any Java program and the building blocks of OOPS as the four pillars use them to make our code modular, maintainable and flexible. Let’s revisit these concepts with a practical mindset and some real-world examples to see how they truly work&lt;/p&gt;

&lt;p&gt;Let’s start...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Different OOPS Concepts in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As mentioned earlier, in this blog we’ll focus on some of the core concepts of Object-Oriented Programming (OOP), which are essential for writing clean and effective code in Java. Without a solid understanding of these OOPS concepts, it’s hard to fully appreciate the power of OOP and use it to make our code modular, flexible, and secure.&lt;/p&gt;

&lt;p&gt;In this post, we’ll concentrate on five key concepts: classes, objects, methods, access modifiers, and constructors. While there are many other important OOP concepts, we’ve chosen these because they are especially relevant for beginners for will help them understand OOP better. The more advanced topics will be covered in future posts, as they require a deeper conceptual understanding.&lt;/p&gt;

&lt;p&gt;Among these five, we’ll be creating separate blog posts for constructors and access modifiers, since they deserve a more detailed explanation. Understanding them is crucial both from a conceptual standpoint and for practical coding in Java.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1vnyp5qnrjnpi8ckibo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1vnyp5qnrjnpi8ckibo.png" alt="OOPS Concepts" width="300" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A class is a blueprint of an object or rather a blueprint that is used to create an object as it tells us which properties and methods will that object or objects of similar kind have. As Java likes to work on the DRY principle. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/oops-concepts-101-what-are-the-key-concepts-you-need-to-know/" rel="noopener noreferrer"&gt;Continue Reading...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>oops</category>
      <category>object</category>
      <category>java</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding Event Bubbling in JavaScript and Its Working</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Sat, 03 Jun 2023 19:35:32 +0000</pubDate>
      <link>https://dev.to/ateevduggal/understanding-event-bubbling-in-javascript-and-its-working-3c56</link>
      <guid>https://dev.to/ateevduggal/understanding-event-bubbling-in-javascript-and-its-working-3c56</guid>
      <description>&lt;p&gt;Understanding the concept of event bubbling in JavaScript is crucial for developers to create dynamic and efficient web applications. Imagine a webpage with multiple elements like buttons, images, and text. Now, let’s say an element was clicked, but which one? We know because we have clicked it, but how will the browser know? That’s where event bubbling comes into play!&lt;/p&gt;

&lt;p&gt;Event bubbling facilitates the seamless detection and handling of associated events as they propagate through an element’s ancestors. This hierarchical event propagation lies at the core of JavaScript’s event system, enabling enhanced flexibility and comprehensive event management capabilities within web applications.&lt;/p&gt;

&lt;p&gt;In this comprehensive guide, we will delve into the fascinating concept of event bubbling in JavaScript. As passionate developers, we understand the importance of mastering these fundamental aspects of JavaScript, as it forms the backbone of event handling in web development.&lt;/p&gt;

&lt;p&gt;In this blog, we will cover many things like the default behavior of event propagation, event bubbling, capturing definitions and use cases, and their differences. &lt;/p&gt;

&lt;p&gt;We hope you like it.&lt;/p&gt;

&lt;p&gt;Let’s start…&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is Event Propagation?&lt;/li&gt;
&lt;li&gt;What is Event Bubbling?&lt;/li&gt;
&lt;li&gt;How does Event Bubbling Work?&lt;/li&gt;
&lt;li&gt;Event Capturing&lt;/li&gt;
&lt;li&gt;Understanding the Concept of Event Bubbling in JavaScript with the Help of a Code&lt;/li&gt;
&lt;li&gt;Briefly Understanding Event and Event Listeners of JavaScript&lt;/li&gt;
&lt;li&gt;Understanding Event Capturing Using Code&lt;/li&gt;
&lt;li&gt;Event Target Phase&lt;/li&gt;
&lt;li&gt;Accessing the Event Object&lt;/li&gt;
&lt;li&gt;How to Stop Event Propagation&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Frequently Asked Questions&lt;/li&gt;
&lt;li&gt;How to Stop Event Capturing?&lt;/li&gt;
&lt;li&gt;What is the difference between Event Bubbling and Event Delegation?&lt;/li&gt;
&lt;li&gt;What is Event Bubbling and How to Stop it?&lt;/li&gt;
&lt;li&gt;Difference between Event Bubbling and Event Capturing?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Event Propagation?
&lt;/h2&gt;

&lt;p&gt;Before moving forward with Event Bubbling, we first have to understand Event Propagation and the various ways in which events propagate in JavaScript. Event propagation is a concept in JavaScript that describes how events are handled in the Document Object Model (DOM) tree. It involves two phases: capturing and bubbling.&lt;/p&gt;

&lt;p&gt;During the capturing phase, the event traverses from the outermost parent element down to the target element, allowing ancestor elements to capture the event along the way.&lt;/p&gt;

&lt;p&gt;Once the event reaches the target element, the target phase begins, where event handlers attached directly to the target element are executed.&lt;/p&gt;

&lt;p&gt;After the target phase, the event enters the bubbling phase, where it travels upward through the parent elements, triggering their respective event handlers.&lt;/p&gt;

&lt;p&gt;To visualize this concept, we can represent it using a diagram:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2ZNb_bc5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3csy1ksb2ij5bv4h813e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2ZNb_bc5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3csy1ksb2ij5bv4h813e.png" alt="Event Propagation in JavaScript" width="302" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This diagram illustrates the event propagation flow. The event starts from the topmost parent element, goes through the capturing phase, reaches the target element, and then proceeds to the bubbling phase, propagating it up to the parent elements.&lt;br&gt;
By understanding event propagation, we can handle events at different levels of the DOM hierarchy, providing flexibility and control in event handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Event Bubbling?
&lt;/h2&gt;

&lt;p&gt;When an event gets triggered within the nested set of HTML elements, this event bubbles up from that element to the outermost element of the nested HTML elements, this process is called event bubbling. During this process, event listeners attached to those elements which were involved in the bubbling process of that event also get triggered like a ripple in a pond.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/understanding-event-bubbling-in-javascript-and-its-working/"&gt;Continue...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Detect a Click Outside of a React Component using Hooks?</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Fri, 26 May 2023 18:55:14 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-detect-a-click-outside-of-a-react-component-using-hooks-3a2m</link>
      <guid>https://dev.to/ateevduggal/how-to-detect-a-click-outside-of-a-react-component-using-hooks-3a2m</guid>
      <description>&lt;p&gt;As web developers, we may come across situations where we might have to detect when a user clicks outside of a specific element, such as a modal or dropdown menu. This can be useful for closing the element or triggering some other action when the user clicks outside of it.&lt;/p&gt;

&lt;p&gt;In React, you can detect a click outside of a component by using a technique called "event bubbling" or "event capturing". This involves attaching an event listener to the document object and checking if the click target is outside of the component. &lt;/p&gt;

&lt;p&gt;In this blog post, we'll understand how to detect a click outside of a React component using the &lt;a href="https://www.knowledgehut.com/blog/web-development/react-useref"&gt;&lt;code&gt;useRef&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://tekolio.com/explaining-useeffect-hook-in-react/"&gt;&lt;code&gt;useEffect&lt;/code&gt;&lt;/a&gt; hooks in a step-by-step fashion using an example problem as it is better to understand things using practical examples.&lt;/p&gt;

&lt;p&gt;Let’s start, but first to create a React app to understand this concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Creating the React App&lt;/li&gt;
&lt;li&gt;What are we making?&lt;/li&gt;
&lt;li&gt;Working on the App&lt;/li&gt;
&lt;li&gt;Detecting the Outside Click of a functional component&lt;/li&gt;
&lt;li&gt;Use a React Ref to Create a Clickable Area&lt;/li&gt;
&lt;li&gt;Creating an event listener for the clickable area&lt;/li&gt;
&lt;li&gt;Checking if the click is outside of the React component&lt;/li&gt;
&lt;li&gt;logic inside the if statement.&lt;/li&gt;
&lt;li&gt;Different Ways using which we can Detect a Click Outside of a React Component&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Frequently Asked Question&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What are we making?
&lt;/h2&gt;

&lt;p&gt;In this app, we will be making a counter app that contains a button wrapped up by a div. The initial value of the counter is 0. With each button click, the value of the counter gets increased by 1, while will decrease if anything other than the button and the wrapper element div is clicked.  See the gif below to understand&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q46ePpmT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6rtomf908vzf5ri67zn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q46ePpmT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6rtomf908vzf5ri67zn.gif" alt="Detecting a click outside a component" width="800" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/how-to-detect-a-click-outside-of-a-react-component-using-hooks/"&gt;Continue Reading...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reacthooks</category>
      <category>useeffect</category>
      <category>usere</category>
    </item>
    <item>
      <title>How to Implement Infinite Scrolling in React by Creating a Custom Hook</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Tue, 02 May 2023 06:59:56 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-implement-infinite-scrolling-in-react-using-hooks-4ha4</link>
      <guid>https://dev.to/ateevduggal/how-to-implement-infinite-scrolling-in-react-using-hooks-4ha4</guid>
      <description>&lt;p&gt;We often find ourselves in a situation where we have to deal with large sums of data in our Applications for user experience. If we render the data, in the same way, using the map function, the DOM Tree and the efficiency of our app will suffer the consequences like effects on speed and loading time, etc.&lt;/p&gt;

&lt;p&gt;There are four solutions to this problem, and infinite scrolling in React is one of them. Infinite scrolling has become a popular feature in modern web applications, allowing users to seamlessly scroll through a large amount of content without clicking through multiple pages.&lt;/p&gt;

&lt;p&gt;In this blog post, we will not only learn how to implement infinite scroll in React using a custom hook so that we can apply it in any application but also the different ways using which we can implement it in our React App.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is an Infinite Scroll?&lt;/li&gt;
&lt;li&gt;Creating the React App&lt;/li&gt;
&lt;li&gt;Understanding the UI of the App&lt;/li&gt;
&lt;li&gt;Getting Data from the API&lt;/li&gt;
&lt;li&gt;Creating the Custom Hook — React Infinite Scroll Hook&lt;/li&gt;
&lt;li&gt;Working on the UI of the main component&lt;/li&gt;
&lt;li&gt;Detecting the Bottom of the Page&lt;/li&gt;
&lt;li&gt;The Pros and Cons of Infinite Scroll&lt;/li&gt;
&lt;li&gt;Tips for Debugging infinite scrolling in React&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is an infinite scroll?
&lt;/h2&gt;

&lt;p&gt;Infinite scrolling is a web design technique that uses lazy loading to load only the content that is currently visible to the user, and as the user scrolls down, it loads more content automatically Instead of clicking a “next” button like we did when we make a pagination component,&lt;/p&gt;

&lt;p&gt;It creates a seamless browsing experience for the user and can help keep them engaged on the site for extended periods. React Infinite scroll component is often used in social media platforms, online marketplaces, and other types of websites where there is a large amount of content to be displayed.&lt;/p&gt;

&lt;p&gt;Now that we know what infinite scrolling is, and how useful it is for our apps, let's make one for ourselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the React App
&lt;/h2&gt;

&lt;p&gt;First and foremost we have to create our React app. It’s straightforward to create a React app — just go to your working directory in your preferred IDE and enter the following command in the terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app infinite-scrolling-in-react&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you are unsure how to set up a create-react-app project properly, you can refer to the official guide here at create-react-app-dev.‌‌&lt;/p&gt;

&lt;p&gt;After the setup, run npm start in the same terminal to start localhost:3000 where our React app will be hosted. We can also see all our changes there.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We will be using Bootstrap for default styling and the rest will be done by custom CSS which will not be discussed in this blog as the main focus of this blog is explaining the construction and use of the different components that we have made in this app like a custom hook for implementing infinite scroll. But for people who want to practice the styling part as well, here is the &lt;a href="https://github.com/Ateevduggal/Infinite-Scrolling-in-React"&gt;GitHub repo &lt;/a&gt;of this project and the &lt;a href="https://infinite-scrolling-in-react.vercel.app/"&gt;live link&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Understanding the UI of the App
&lt;/h2&gt;

&lt;p&gt;Our app contains a number of cards containing a dummy image, name, and description generated from a test API and displayed in the form of cards as shown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f2pKXs4f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqkg0g5fd93ijahsn1dg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f2pKXs4f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqkg0g5fd93ijahsn1dg.png" alt="Image description" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/how-to-implement-infinite-scrolling-in-react-by-making-a-custom-hook/"&gt;Continue Reading...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>hooks</category>
      <category>infinitescrolling</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Trouble accessing context values with useContext in child component</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Wed, 19 Apr 2023 08:22:26 +0000</pubDate>
      <link>https://dev.to/ateevduggal/trouble-accessing-context-values-with-usecontext-in-child-component-1fg3</link>
      <guid>https://dev.to/ateevduggal/trouble-accessing-context-values-with-usecontext-in-child-component-1fg3</guid>
      <description>&lt;p&gt;I am making Google Keep Clone with React and Context API (useContext hook). It was going very smoothly, everything was coming in proper order until I thought of somehow passing the notes from home to the archive and delete section using a button. For this purpose, I have used useContext hook so that I can avoid unnecessary prop drilling and complex codes. But somehow it's not working. Can anyone help me?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { createContext, useState } from "react";
export const dataContext = createContext([]);

const Context = ({ children }) =&amp;gt; {
  const [addData, setAddData] = useState([]); //to store all the values of the state data
  const [archive, setArchive] = useState([]);
  const [deleteNotes, setDeleteNotes] = useState([]);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;dataContext.Provider
        value={{
          addData,
          setAddData,
          archive,
          setArchive,
          deleteNotes,
          setDeleteNotes,
        }}
      &amp;gt;
        {children}
      &amp;lt;/dataContext.Provider&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default Context;
// export { dataContext };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useContext, useState } from "react";
import Inputbox from "../Components/Inputbox";
import { dataContext } from "../Components/Context";
import { v4 as uuid } from "uuid";
import SingleNote from "../Components/SingleNote";

const Notes = () =&amp;gt; {
  const [loading, setLoading] = useState(true);
  const { addData, setAddData, setArchive, setDeleteNotes } =
    useContext(dataContext);
  //Math.random can also be used here but to make things simpler we have used a npm package as we don't know how many notes will a person will save
  const [show, setShow] = useState(false); //to toggle between between the main note and the big note

  const [data, setData] = useState({
    //to stores all the values given by the user
    id: uuid(),
    title: "",
    description: "",
  });

  const addNote = () =&amp;gt; {
    setAddData((oldData) =&amp;gt; {
      return [...oldData, data]; // Calling the done function using the addNote function
    });
  };

  const Delete = (index) =&amp;gt; {
    const DelArray = addData.filter((Val) =&amp;gt; {
      return index !== Val.id;
    });
    setAddData(DelArray);
    setDeleteNotes((preArr) =&amp;gt; [addData, ...preArr]);
  };

  const Archive = (index) =&amp;gt; {
    const ArchiveArray = addData.filter((Val) =&amp;gt; {
      return index !== Val.id;
    });
    setAddData(ArchiveArray);
    setArchive((preArr) =&amp;gt; [addData, ...preArr]);
  };

  const handleClickAway = (e, val) =&amp;gt; {
    e.preventDefault();
    setShow(false); //if data filed is blank, close the input fields
    //if data field is not empty
    if (data.title || data.description) {
      setLoading(false);
      addNote(val);
      setData({
        title: "",
        description: "",
      });
    }
  };
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Inputbox
        handleClickAway={handleClickAway}
        data={data}
        setData={setData}
        setAddData={setAddData}
        show={show}
        setShow={setShow}
      /&amp;gt;
      {loading ? (
        &amp;lt;div style={{ marginLeft: "30%", marginTop: "5%" }}&amp;gt;
          &amp;lt;div className="icon-1"&amp;gt;
            &amp;lt;i class="fa-regular fa-note-sticky"&amp;gt;&amp;lt;/i&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="fs-3 fw-bold opacity-50"&amp;gt;
            Your Notes will Appear Here
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      ) : (
        &amp;lt;SingleNote addData={addData} Delete={Delete} Archive={Archive} /&amp;gt;
      )}
    &amp;lt;/&amp;gt;
  );
};

export default Notes;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";

const SingleNote = ({ addData, Delete, Archive }) =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="row mt-5 d-flex"&amp;gt;
        {addData &amp;amp;&amp;amp;
          addData.map((Val, index) =&amp;gt; {
            const { title, description, id } = Val;
            return (
              &amp;lt;&amp;gt;
                &amp;lt;div className="note m-3" key={index} id={index}&amp;gt;
                  &amp;lt;div className="fs-4 fw-bold"&amp;gt;{title}&amp;lt;/div&amp;gt;
                  &amp;lt;br /&amp;gt;
                  &amp;lt;p&amp;gt;{description}&amp;lt;/p&amp;gt;
                  &amp;lt;div className="d-flex flex-row-reverse"&amp;gt;
                    &amp;lt;div
                      onClick={() =&amp;gt; Delete(id)}
                      style={{ cursor: "pointer" }}
                      title="Delete"
                    &amp;gt;
                      &amp;lt;i className="fa-regular fa-trash-can fs-4 py-2 text-danger mx-3"&amp;gt;&amp;lt;/i&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div
                      onClick={() =&amp;gt; Archive(id)}
                      style={{ cursor: "pointer" }}
                      title="Archive"
                    &amp;gt;
                      &amp;lt;i className="fa-solid fa-boxes-stacked fs-4 py-2 text-success"&amp;gt;&amp;lt;/i&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/&amp;gt;
            );
          })}
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default SingleNote;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useContext } from "react";
import { dataContext } from "../Components/Context";

const Archive = () =&amp;gt; {
  const { archive, setAddData, setArchive, setDeleteNotes } =
    useContext(dataContext);

  const Delete = (index) =&amp;gt; {
    const DelArray = archive[0].filter((Val) =&amp;gt; {
      return index !== Val.id;
    });
    setDeleteNotes(DelArray);
    setAddData((preArr) =&amp;gt; [archive, ...preArr]);
  };

  const UnArchive = (index) =&amp;gt; {
    const ArchiveArray = archive[0].filter((Val) =&amp;gt; {
      return Val.id !== index;
    });
    setArchive(ArchiveArray);
    setAddData((preArr) =&amp;gt; [...preArr, archive]);
  };
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="row mt-5 d-flex"&amp;gt;
        {archive.map((Val, index) =&amp;gt; {
          const entry = Val[0];
          const { title, description, id } = entry;
          return (
            &amp;lt;&amp;gt;
              &amp;lt;div className="note m-3" key={index} id={index}&amp;gt;
                &amp;lt;div className="fs-4 fw-bold"&amp;gt;{title}&amp;lt;/div&amp;gt;
                &amp;lt;br /&amp;gt;
                &amp;lt;p&amp;gt;{description}&amp;lt;/p&amp;gt;
                &amp;lt;div className="d-flex flex-row-reverse"&amp;gt;
                  &amp;lt;div
                    onClick={() =&amp;gt; Delete(id)}
                    style={{ cursor: "pointer" }}
                    title="Delete"
                  &amp;gt;
                    &amp;lt;i className="fa-regular fa-trash-can fs-4 py-2 text-danger mx-3"&amp;gt;&amp;lt;/i&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div
                    onClick={() =&amp;gt; UnArchive(id)}
                    style={{ cursor: "pointer" }}
                    title="Unarchive"
                  &amp;gt;
                    &amp;lt;i className="fa-solid fa-arrow-up-from-ground-water fs-4 py-2 text-success"&amp;gt;&amp;lt;/i&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/&amp;gt;
          );
        })}
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default Archive;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the problem that I am facing is I can send the data from the notes component to the archive component, but it's not coming back from the archive component to the notes component. PLease help me.&lt;/p&gt;

</description>
      <category>question</category>
      <category>react</category>
      <category>hooks</category>
      <category>usecontext</category>
    </item>
    <item>
      <title>How to build a Movie App in React using TMDB API</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Mon, 27 Mar 2023 05:44:30 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-build-a-movie-app-in-react-using-tmdb-api-4n54</link>
      <guid>https://dev.to/ateevduggal/how-to-build-a-movie-app-in-react-using-tmdb-api-4n54</guid>
      <description>&lt;p&gt;React Movie App or Movie App in React is a fun project that every React developer should make once, in order to improve/ enhance/ polish their React coding skills. It is a must considering AIs like ChatGPT which can do pretty much anything even coding are now among us. So it’s better to understand these concepts well in order to use them in our future projects&lt;/p&gt;

&lt;p&gt;In this blog, we will be making a movie app in React using TMDB API by using some very easy but tricky concepts to make our app more entertaining. These concepts are -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetching data from API&lt;/li&gt;
&lt;li&gt;Displaying data in the form of a card&lt;/li&gt;
&lt;li&gt;Pagination&lt;/li&gt;
&lt;li&gt;Filtering data of both Movies and TV Shows based on their genre&lt;/li&gt;
&lt;li&gt;A custom hook to help us in this filtering process&lt;/li&gt;
&lt;li&gt;A Custom Search Bar using which we can search movies as well as tv series.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;We will be using Bootstrap for default styling and the rest will be done by custom CSS which will not be discussed in this blog as the main focus of this blog is explaining the construction and use of the different components that we have made in this app like the Filter Component, Custom Hook, etc. But for people who want to practice the styling part as well, here is the &lt;a href="https://github.com/Ateevduggal/The-Movie-Central"&gt;GitHub repo&lt;/a&gt; of this project and the live link.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s Start…&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Creating the React App&lt;/li&gt;
&lt;li&gt;Getting data from TMDB API&lt;/li&gt;
&lt;li&gt;Working on the UI part of the App&lt;/li&gt;
&lt;li&gt;Creating different pages of our App&lt;/li&gt;
&lt;li&gt;Creating the Trending Page&lt;/li&gt;
&lt;li&gt;Creating the Movies Page&lt;/li&gt;
&lt;li&gt;Creating the TV Series Page&lt;/li&gt;
&lt;li&gt;Creating the Custom Search Page&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Creating the React App
&lt;/h2&gt;

&lt;p&gt;First and foremost we have to create our React app. It’s straightforward to create a React app — just go to your working directory in your preferred IDE and enter the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app the-movie-central
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are unsure how to set up a create-react-app project properly, you can refer to the official guide here at create-react-app-dev.‌‌&lt;/p&gt;

&lt;p&gt;After the setup, run npm start in the same terminal to start localhost:3000 where our React app will be hosted. We can also see all our changes there.&lt;/p&gt;

&lt;p&gt;Our movie app wouldn’t be any good if we didn’t have any movies to display. So to solve this issue we will be using the TMDB API as our source for movies and other stuff related to it. This API is free to use, and all we have to do is sign up and get an API key. Let’s see how.&lt;/p&gt;

&lt;p&gt;Getting the API Key from TMDB’s official website&lt;br&gt;
TMDB stands for The Movie DataBase which is basically an online database that contains information related to films, television programs, and video games. It is a community-built resource, open to anyone who would like to contribute.&lt;/p&gt;

&lt;p&gt;The TMDB API provides access to detailed information about movies, television shows, actors, crew members, and more. The API includes over 3 million pieces of data, including movie posters, release dates, cast and crew information, plot summaries, and more.&lt;/p&gt;

&lt;p&gt;And we are going to take advantage of all these features that this API is providing while making our Movie App, though we will be limiting ourselves to the Movie Section and the TV Series Section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/how-to-build-a-movie-app-in-react-using-tmdb-api/"&gt;Continue Reading…&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>hooks</category>
      <category>api</category>
      <category>tmdb</category>
    </item>
    <item>
      <title>A Guide to React Context API and useContext hook</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Fri, 17 Feb 2023 10:08:44 +0000</pubDate>
      <link>https://dev.to/ateevduggal/a-guide-to-react-context-api-and-usecontext-hook-53k</link>
      <guid>https://dev.to/ateevduggal/a-guide-to-react-context-api-and-usecontext-hook-53k</guid>
      <description>&lt;p&gt;React Context API was introduced a while ago with React version 16.3. It was mainly introduced to solve one of the major problems that React developers like us were facing at that time - prop drilling and component re-rendering. In this article, we will cover the reasons which led to the birth of Context API and a lot more topics related to it, with step-by-step explanations. &lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is React Context API?&lt;/li&gt;
&lt;li&gt;What is Prop Drilling?&lt;/li&gt;
&lt;li&gt;How does React Context API work?&lt;/li&gt;
&lt;li&gt;Understanding React Context API&lt;/li&gt;
&lt;li&gt;What is useContext hook?&lt;/li&gt;
&lt;li&gt;React Context API VS Redux&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;li&gt;Frequently Asked Questions&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is React Context API
&lt;/h2&gt;

&lt;p&gt;Context API in React JS is an in-built API feature of React that manages props and states globally. Simply said, it is a way of passing the data from the parent to the child component - its final destination, without going through every other child component.&lt;br&gt;
Imagine a situation where we have to pass down data from a parent component to the last child component. One way is to manually pass down the data in the form of props to every other child component until it has reached the last child component - where it has to be used. This process is called prop drilling and it complicates our overall code and can even make it ugly.&lt;br&gt;
What we can do to avoid prop drilling is we can make a global state variable with the help of the createContext() function of React, store and fetch all state management variables from it using methods like Provider and Consumer and we can even use a hook to make things even simpler as they are globally stored. See the image below to understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Prop drilling?
&lt;/h2&gt;

&lt;p&gt;In a typical React Application, we use props to pass down the data from parent to child, but sometimes it can become a hassle as it can create a lot of complex codes mainly when we are dealing with some pretty heavy coding stuff like creating a UI Theme, Authenticating user credentials, etc. &lt;/p&gt;

&lt;p&gt;In cases like these, if we use the same method of passing props from parent to child component until it has reached its final destination, it will not become a thing of beauty but will become something so complicated that sometimes we, who have written it, might get confused, and this is called prop drilling.&lt;/p&gt;

&lt;p&gt;Prop Drilling is a situation where data is passed down from a parent component to multiple child components until it has reached its final destination. Prop Drilling not only complicates our code but also consumes a lot of space and can sometimes be the root of re-rendering.&lt;/p&gt;

&lt;p&gt;This is simply because whenever we pass a prop down the component, our App gets re-rendered and in the case of prop drilling, there can be multiple re-renders. To avoid this, the concept of Context API was introduced in both class and functional components. In this article, we will mainly see how to use React Context API with functional components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/a-guide-to-react-context-api-and-usecontext-hook/" rel="noopener noreferrer"&gt;Continue Reading...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Explaining TreeMap in Java in Simple English</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Sat, 05 Nov 2022 20:08:14 +0000</pubDate>
      <link>https://dev.to/ateevduggal/explaining-treemap-in-java-in-simple-english-3j91</link>
      <guid>https://dev.to/ateevduggal/explaining-treemap-in-java-in-simple-english-3j91</guid>
      <description>&lt;p&gt;TreeMap in Java, just like the HashMap, is part of the java collection framework. It is a red-black tree-based implementation of the Map interface, NavigableMap, and AbstractMap classes. It stores data in the form of Key and Value pairs where the key is a unique identifier used to associate each value on the Map. It means that every key is mapped to exactly one value and that we can use it to retrieve its corresponding value from the map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tFIH6WWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1ubmlh2qsb5y19jgofv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tFIH6WWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1ubmlh2qsb5y19jgofv.png" alt="TreeMap in Java" width="793" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a general idea about TreeMap, Let’s dive into its more advanced features for a better understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is a TreeMap?&lt;/li&gt;
&lt;li&gt;Initializing a TreeMap&lt;/li&gt;
&lt;li&gt;Features of TreeMap&lt;/li&gt;
&lt;li&gt;Why is TreeMap not Synchronized in Nature?&lt;/li&gt;
&lt;li&gt;Internal Structure of TreeMap.&lt;/li&gt;
&lt;li&gt;Basic Operations of TreeMap.&lt;/li&gt;
&lt;li&gt;Some more Methods of TreeMap in Java&lt;/li&gt;
&lt;li&gt;Constructors in TreeMap&lt;/li&gt;
&lt;li&gt;Sorting in TreeMap&lt;/li&gt;
&lt;li&gt;Internal Working of TreeMap&lt;/li&gt;
&lt;li&gt;Red-Black Tree Algorithm&lt;/li&gt;
&lt;li&gt;Step-by-Step Procedure for Working on TreeMap&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Frequently Asked Question&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is a TreeMap?
&lt;/h2&gt;

&lt;p&gt;As mentioned above, TreeMap is nothing more than a Data Structure that stores data in the form of the key and value pair, where the key should be a unique identifier that allows us to perform multiple operations like add, delete, replace, etc on the data stored in the TreeMap.&lt;/p&gt;

&lt;p&gt;Unlike HashMap which only takes a constant time, it takes a logarithmic time to perform the above-mentioned operations. This makes one wonder why it was introduced in the first place. The answer is simple…to save the memory used to store data. It only uses the amount of memory needed to hold/ store the items, unlike a HashMap which uses a contiguous region of memory.&lt;/p&gt;

&lt;p&gt;The best thing about TreeMap is that here storing of data is done based on the natural ordering of keys — if keys are initialized as integers then they will be stored in ascending order of the keys, and if the keys are initiated as String or characters, then the data will be stored in the alphabetic order.&lt;/p&gt;

&lt;p&gt;But in the case of TreeMap custom sorting is also possible. For that, we have to use a specific type of constructor to perform this custom sort which we will see later in the blog.&lt;/p&gt;

&lt;p&gt;The ordering maintained by a TreeMap (just like any other sorted map) must be compatible with the equal sign if it correctly wants to implement the Map interface irrespective of whether a constructor is provided or not. This is because all the operations performed on the map Interface use the equal operator, while all the operations performed on the Sorted map use its compareTo or compare method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initializing a TreeMap
&lt;/h2&gt;

&lt;p&gt;Creating a TreeMap is the same as creating a HashMap in Java. Just like in HashMap, first, we have to import the TreeMap class from the util package and then write the following line to create a new TreeMap in Java and use all its methods and constructor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TreeMap&amp;lt;Key, Value&amp;gt; numbers = new TreeMap&amp;lt;&amp;gt;()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here&lt;/p&gt;

&lt;p&gt;key — is the unique identifier used to associate each element in the map&lt;/p&gt;

&lt;p&gt;value — elements associated by keys in a map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/explaining-treemap-in-java-in-simple-english/"&gt;Continue Reading…&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>map</category>
      <category>treemap</category>
    </item>
    <item>
      <title>How to Merge Two Sorted Arrays</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Sat, 05 Nov 2022 19:56:45 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-merge-two-sorted-arrays-4m0</link>
      <guid>https://dev.to/ateevduggal/how-to-merge-two-sorted-arrays-4m0</guid>
      <description>&lt;p&gt;Problem&lt;br&gt;
You are given two sorted arrays A and B of lengths m and n, the task is to merge the two sorted arrays in such a way that the merged array is also sorted.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Input&lt;/strong&gt;&lt;br&gt;
A[] = {3, 9, 10, 18, 23}&lt;br&gt;
B[] = {5, 12, 15, 20, 21, 25}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
Merged[] = {3, 5, 9, 10, 12, 15, 18, 20, 21, 23, 25}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The merged array is of the size of n + m and contains both the elements of array A and array B in sorted order&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt;&lt;br&gt;
A[] = { 5, 8, 9}&lt;br&gt;
B[] = {4, 7, 8}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Merged[] = {4, 5, 7, 8, 8, 9}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The merged array is of the size of n + m and contains both the elements of array A and array B in sorted order&lt;/p&gt;
&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Brute Force Approach&lt;/li&gt;
&lt;li&gt;Insertion Sort Approach&lt;/li&gt;
&lt;li&gt;Efficient Approach — Using Merge Sort&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Brute Force Approach
&lt;/h2&gt;

&lt;p&gt;The idea is to create a new array C[] of length m+n and put all the elements from A[] and B[] in it and then sort them using Arrays.sort().&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qI2fWw3d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tl5dgsqvur5bxb2io3tq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qI2fWw3d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tl5dgsqvur5bxb2io3tq.png" alt="Merged Array" width="541" height="195"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Algorithm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create an array C of n+m size to store the merged array&lt;/li&gt;
&lt;li&gt;Put the values of both A and B arrays using a for loop&lt;/li&gt;
&lt;li&gt;Sort the C array using Array..sort().&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DEbcx0Lw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ur07djopxu4jxzdvduut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DEbcx0Lw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ur07djopxu4jxzdvduut.png" alt="Simple merging of two sorted arrays" width="758" height="408"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Pseudo Code
&lt;/h2&gt;



&lt;p&gt;&lt;code&gt;Int[] solve(int[] A, int[] B, int n, int m) {&lt;br&gt;
Create a new array C of n+m size&lt;br&gt;
while(i&amp;lt;n) {&lt;br&gt;
C[k++] = A[i++];&lt;br&gt;
}&lt;br&gt;
while(j&amp;lt;m) {&lt;br&gt;
C[k++] = B[j++];&lt;br&gt;
}&lt;br&gt;
Sort C;&lt;br&gt;
return C&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;Array after merging - 1 2 3 4 5 6 7 8&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity&lt;/strong&gt; — O((m+n) log(m+n))&lt;br&gt;
We have sorted an array of size m+n using Arrays.sort(), and the time complexity of this operation is O(n log n) which in this case becomes O((m+n )log(m+n))&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity&lt;/strong&gt; — O(m+n)&lt;br&gt;
We have created a new array C of size n+m which will store the merged sorted array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/how-to-merge-two-sorted-arrays/"&gt;Continue Reading…&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>sorting</category>
    </item>
    <item>
      <title>How to Merge Two Sorted Arrays</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Mon, 12 Sep 2022 00:17:24 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-merge-two-sorted-arrays-3jeo</link>
      <guid>https://dev.to/ateevduggal/how-to-merge-two-sorted-arrays-3jeo</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;You are given two sorted arrays A and B of lengths m and n, the task is to merge the two sorted arrays in such a way that the merged array is also sorted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Input&lt;/strong&gt;&lt;br&gt;
A[] = {3, 9, 10, 18, 23}&lt;br&gt;
B[] = {5, 12, 15, 20, 21, 25}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
Merged[] = {3, 5, 9, 10, 12, 15, 18, 20, 21, 23, 25}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The merged array is of the size of n + m and contains both the elements of array A and array B in sorted order&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt;&lt;br&gt;
A[] = { 5, 8, 9}&lt;br&gt;
B[] = {4, 7, 8}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Merged[] = {4, 5, 7, 8, 8, 9}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The merged array is of the size of n + m and contains both the elements of array A and array B in sorted order&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Brute Force Approach&lt;/li&gt;
&lt;li&gt;Insertion Sort Approach&lt;/li&gt;
&lt;li&gt;Efficient Approach — Using Merge Sort&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Brute Force Approach
&lt;/h2&gt;

&lt;p&gt;The idea is to create a new array C[] of length m+n and put all the elements from A[] and B[] in it and then sort them using Arrays.sort().&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cJUcevEl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xhd9hu9xz941k2wv3oo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cJUcevEl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xhd9hu9xz941k2wv3oo.png" alt="Merged Array" width="541" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Algorithm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create an array C of n+m size to store the merged array&lt;/li&gt;
&lt;li&gt;Put the values of both A and B arrays using a for loop&lt;/li&gt;
&lt;li&gt;Sort the C array using Array..sort().&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XdDgEGx---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trcih0dnfny145n3g4r8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XdDgEGx---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trcih0dnfny145n3g4r8.png" alt="Simple merging of two sorted arrays" width="758" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pseudo Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Int[] solve(int[] A, int[] B, int n, int m) {
Create a new array C of n+m size
while(i&amp;lt;n) {
C[k++] = A[i++];
}
while(j&amp;lt;m) {
C[k++] = B[j++];
}
Sort C;
return C
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;Array after merging - 1 2 3 4 5 6 7 8&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity&lt;/strong&gt; — O((m+n) log(m+n))&lt;br&gt;
We have sorted an array of size m+n using Arrays.sort(), and the time complexity of this operation is O(n log n) which in this case becomes O((m+n )log(m+n))&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity&lt;/strong&gt; — O(m+n)&lt;br&gt;
We have created a new array C of size n+m which will store the merged sorted array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/how-to-merge-two-sorted-arrays/"&gt;Continue Reading…&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>sorting</category>
      <category>java</category>
    </item>
    <item>
      <title>Explaining Selection Sort Algorithm in Simple English</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Mon, 05 Sep 2022 23:10:52 +0000</pubDate>
      <link>https://dev.to/ateevduggal/explaining-selection-sort-algorithm-in-simple-english-103g</link>
      <guid>https://dev.to/ateevduggal/explaining-selection-sort-algorithm-in-simple-english-103g</guid>
      <description>&lt;p&gt;In this Blog, we will discuss the Selection Sort Algorithm and its working procedure. Selection sort is an in-place comparison-based sorting algorithm that sorts the array by repeatedly finding and swapping the minimum element with the leftmost element of the array.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In-place means that the algorithm does not use extra space for manipulating the input but may require a small though non-constant extra space for its operation. Usually, this space is O(log n), though sometimes anything in O(n) (Smaller than linear) is allowed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this algorithm, the array is divided into two parts. One part will initially be empty but will contain the sorted array and is placed on the left-hand side, while the other part carries the original unsorted array and is placed on the right-hand side. In every iteration, the minimum element is picked from the unsorted list and gets placed at the beginning of the sorted array, thus reducing the size of the unsorted array by one while at the same time increasing the size of the sorted array by 1.&lt;/p&gt;

&lt;p&gt;Now that we have understood what selection sort is, let’s understand its working procedure with a simple example of an array with a length of 5.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Selection Sort Algorithm Works
&lt;/h2&gt;

&lt;p&gt;The working principle of this algorithm is very simple. As told, we just have to find the minimum element from the unsorted array and place it at the beginning of the sorted array.&lt;/p&gt;

&lt;p&gt;To begin with we have to assume that the first element of the unsorted subarray is the minimum element of the array. Then by iterating and comparing every element of this unsorted array with the first element which we have assumed to be the minimum element of the array we have to find the minimum element of the array.&lt;/p&gt;

&lt;p&gt;If we find any element less than our current min element, that element becomes the new min of the array and the journey continues till the last element. Upon reaching the end of the array, simply replace the leftmost element of the unsorted array with the current min element. We have to do this every time until the array is sorted completely.&lt;/p&gt;

&lt;p&gt;Let’s take an example of an array of length 5 to understand it better&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PZ0z0rgI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwcxvcb662bo4p1jm3z5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PZ0z0rgI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwcxvcb662bo4p1jm3z5.png" alt="Unsorted Array" width="491" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the array we are using is of length 5, we will be making 4 passes. One pass per element, and as for the last element, it will be automatically sorted. Thus we can say that for an array of size n, n-1 passes are required to sort that array using the selection sort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tekolio.com/explaining-selection-sort-algorithm-in-simple-english/"&gt;Continue Reading…&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>sorting</category>
    </item>
    <item>
      <title>How to make Fireworks in React using Particle JS React.</title>
      <dc:creator>Ateev Duggal</dc:creator>
      <pubDate>Wed, 24 Aug 2022 04:38:51 +0000</pubDate>
      <link>https://dev.to/ateevduggal/how-to-make-fireworks-in-react-using-particle-js-react-4ldd</link>
      <guid>https://dev.to/ateevduggal/how-to-make-fireworks-in-react-using-particle-js-react-4ldd</guid>
      <description>&lt;p&gt;Have you ever thought about how some developers can create stunning background animations like fireworks, confetti, night sky with blinking stars, etc? At first, I thought it was just a video playing at the back, or come crazy developer with some crazy-ass experience made it, but I was wrong as after several hours of research I found a fantastic package that can solve this problem without writing any complex code. The name of the package is Particle JS React which is a lightweight, dependency-free, responsive, and flexible JavaScript plugin which is used to create 2D animations like the ones mentioned above.&lt;/p&gt;

&lt;p&gt;In this blog, we will use this package in React with a little twist. The twist is that we will be using its typescript version which is created specifically for component-based frameworks like React, Angular, and Vue called React TsParticles which is even easier to handle than Particle JS. We will understand how to make a beautiful firework background animation with this TsParticle.JS library or package in React with the help of a Congratulations Page.&lt;/p&gt;

&lt;p&gt;Lets Start…&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction of Particle js&lt;/li&gt;
&lt;li&gt;Creating the React App&lt;/li&gt;
&lt;li&gt;Installing Particle js library&lt;/li&gt;
&lt;li&gt;Importing the library in our app&lt;/li&gt;
&lt;li&gt;Working on the UI part of the App&lt;/li&gt;
&lt;li&gt;Working on the Animation of the App&lt;/li&gt;
&lt;li&gt;Working on the functionality of the App&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;FAQ&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction of TSParticle.JS
&lt;/h2&gt;

&lt;p&gt;Before moving forward with our app, let’s take an overview of the library — Tsparticle that we will be using in this app to make an excellent background animation.&lt;/p&gt;

&lt;p&gt;Below is the GIF of the actual website of TSParticle where we can see all the stunning background animation in action and on the right-hand side on the top we have an options tab which we can use to play around and learn what different options are there and how to use them to get our desired result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the React App
&lt;/h2&gt;

&lt;p&gt;It’s very easy to create a React app — just go to your working directory in your preferred IDE and enter the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app fireworks-app&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If you are unsure how to properly set up a create-react-app project, you can refer to the official guide here at create-react-app-dev.‌‌&lt;/p&gt;

&lt;p&gt;After the setup, run npm start in the same terminal to start localhost:3000 where our React app will be hosted. We can also see all our changes there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing the Particle.Js library
&lt;/h2&gt;

&lt;p&gt;To start using the Particles Js in React we have to first install its typescript version as this version is only made for React and is much simpler to use than the actual one.&lt;/p&gt;

&lt;p&gt;To install it, run the following command in the command prompt or terminal which is already running at the back of the project we have just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For npm users
npm i react-tsparticles 
npm i tsparticles

For yarn users
yarn add react-tsparticles
yarn add tsparticles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also install the react-tsparticles while creating our react app with the below-given command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ create-react-app your_app –template particles&lt;br&gt;
or&lt;br&gt;
$ create-react-app your_app –template particles-typescript&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If any legacy error shows, use –force for npm users as this will forcefully update everything&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i react-tsparticles –force&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;npm i tsparticles –force&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing the TSParticles Js Library in our App
&lt;/h2&gt;

&lt;p&gt;Just like any other package, we first have to import the library from the node modules in the App.js file so that we can start using it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import Particles from "react-tsparticles";
import { loadFull } from "tsparticles";
const App = () =&amp;gt; {
return &amp;lt;div&amp;gt;Hello&amp;lt;/div&amp;gt;;
};
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Working on the UI part of the App.
&lt;/h2&gt;

&lt;p&gt;This part will be further divided and discussed in two parts. The first part contains the text and the styling part of our app which we have done using some Vanilla CSS and Bootstrap, while in the other we will discuss how we have made the fireworks animation using the TSParticle.js package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import Particles from "react-tsparticles";
import { loadFull } from "tsparticles";
const App = () =&amp;gt; {
return (
&amp;lt;&amp;gt;
&amp;lt;h1 className="text-white display-3 fw-bold mt-5 text-center"&amp;gt;
Congratulations
&amp;lt;/h1&amp;gt;
&amp;lt;h3 className="text-white fs-5 mt-3 mb-5 text-center"&amp;gt;
You are among the top 5% of the people who have reached here.
&amp;lt;/h3&amp;gt;
&amp;lt;div className="trophy d-flex justify-content-center mt-5"&amp;gt;
&amp;lt;i className="fa-solid fa-award t-1"&amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;i className="fa-solid fa-award t-2"&amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;i className="fa-solid fa-award t-3"&amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div className="text-center mt-4 pt-4"&amp;gt;
&amp;lt;button className="btn btn-danger fs-3 fw-bold text-white"&amp;gt;
Keep Going ----&amp;gt;
&amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/&amp;gt;
);
};
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://tekolio.com/how-to-make-fireworks-in-react-with-particle-js-react/"&gt;Continue Reading&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>particlejs</category>
    </item>
  </channel>
</rss>
