<?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>Forem: Adavize A.</title>
    <description>The latest articles on Forem by Adavize A. (@adavize).</description>
    <link>https://forem.com/adavize</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%2F254888%2Fa551ecb2-1f5f-423a-804b-f68d10e57bfc.png</url>
      <title>Forem: Adavize A.</title>
      <link>https://forem.com/adavize</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/adavize"/>
    <language>en</language>
    <item>
      <title>Simplified Responsive Web Development with SCSS/SASS</title>
      <dc:creator>Adavize A.</dc:creator>
      <pubDate>Sat, 11 Mar 2023 12:45:00 +0000</pubDate>
      <link>https://forem.com/adavize/simplified-responsive-web-development-with-scsssass-1pn8</link>
      <guid>https://forem.com/adavize/simplified-responsive-web-development-with-scsssass-1pn8</guid>
      <description>&lt;p&gt;Building responsive webpages can be challenging, especially when it comes to managing breakpoints and media queries. However, using SCSS can make this task much more manageable and efficient.&lt;/p&gt;

&lt;p&gt;In this article, we will explore a helpful SCSS pattern for managing breakpoints and creating media queries. Please note that this tutorial assumes some basic knowledge of CSS and media queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Brief Introduction to SCSS
&lt;/h2&gt;

&lt;p&gt;For readers unfamiliar with SCSS, it is a CSS preprocessor that lets you write CSS styles with added functionalities.&lt;/p&gt;

&lt;p&gt;With SCSS, you can have variables, loops, functions, and lots more in your stylesheet. In the end, it compiles to regular CSS code that web browsers understand. &lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://sass-lang.com/"&gt;sass-lang.com&lt;/a&gt;, SCSS is CSS with superpowers. It makes styling a whole lot easier and faster; let's explore.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Approach - Preview
&lt;/h2&gt;

&lt;p&gt;Say we have elements with the class name &lt;code&gt;list-item&lt;/code&gt; and we want to achieve the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On small screen widths, we want a font-size of &lt;code&gt;18px&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;Then on larger screen widths, we want a font-size of &lt;code&gt;25px&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's a preview of how it works using this approach:&lt;/p&gt;

&lt;p&gt;SCSS Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt; &lt;span class="nc"&gt;.list-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="k"&gt;@include&lt;/span&gt; &lt;span class="nd"&gt;sm&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compiled CSS Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.list-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="nf"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.list-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen above, &lt;code&gt;@include sm&lt;/code&gt; is all that was needed.    &lt;/p&gt;

&lt;h2&gt;
  
  
  Why this approach?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Simplicity and Maintainability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the example above, we see that the responsive styles are nested within the same selector.&lt;/p&gt;

&lt;p&gt;So whenever there is a need to maintain the rules for a selector, you'd have all of them in one place, instead of travelling through different media-query sections and redefining rules.&lt;/p&gt;

&lt;p&gt;Also, it comes with simple conventional labels. If you're used to styling libraries with classes such as "col-sm-2" and "col-md-4", you can achieve this in your stylesheets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;@include&lt;/span&gt; &lt;span class="nd"&gt;sm&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1fr&lt;/span&gt; &lt;span class="m"&gt;1fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;@include&lt;/span&gt; &lt;span class="nd"&gt;md&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;This is achieved by combining the powers of SCSS &lt;strong&gt;mixins&lt;/strong&gt; and &lt;strong&gt;content blocks&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
&lt;a href="https://sass-lang.com/documentation/at-rules/mixin"&gt;Mixins&lt;/a&gt; let you define reusable style blocks, and &lt;code&gt;content&lt;/code&gt; lets you project/embed styles into an already defined mixin.&lt;/p&gt;

&lt;p&gt;Below is SCSS code that defines a mixin for small breakpoint - &lt;code&gt;sm&lt;/code&gt; and embeds a &lt;code&gt;media query&lt;/code&gt; for &lt;code&gt;600px&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;
 &lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nf"&gt;sm&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

     &lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="nf"&gt;and&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
         &lt;span class="k"&gt;@content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// projected content will be embedded here&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C'est fini! Now whenever a selector needs specific styles for this media query, we include the mixin using its name, &lt;code&gt;@include sm {...}&lt;/code&gt;.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Mobile First Consideration
&lt;/h2&gt;

&lt;p&gt;Mobile first approach is a method of styling that prioritizes small screens. Styles are written for small screens first, then modified with queries for larger screens.&lt;/p&gt;

&lt;p&gt;The examples used in this article so far follows this principle, but there are cases where the reverse is required.&lt;/p&gt;

&lt;p&gt;I like to have mixins available for both methods. The major difference in the media queries are &lt;code&gt;min-width:&lt;/code&gt; and &lt;code&gt;max-width:&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I have created an SCSS snippet that contains my default breakpoints, you can find it on GitHub - &lt;a href="https://gist.github.com/adavize0/b18a6450d77920028b16a102713b6ff3"&gt;breakpoints.scss&lt;/a&gt;.    &lt;/p&gt;

&lt;h2&gt;
  
  
  Bundle Size Consideration
&lt;/h2&gt;

&lt;p&gt;Using this approach may leave your final CSS output with many media query declarations. This is because for every &lt;code&gt;@include&lt;/code&gt;, a corresponding media query is generated.&lt;/p&gt;

&lt;p&gt;Depending on the size of your project, generating so many media query declarations may greatly affect its bundle size. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Every byte matters.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you are very conscious about application bundle size, like I am, worry not. Thankfully there is a webpack plugin that groups similar media queries.&lt;/p&gt;

&lt;p&gt;Hence, in your final CSS output, you get the old-fashioned single media query declaration (Yaaaay!).&lt;/p&gt;

&lt;p&gt;Kindly checkout the &lt;a href="https://www.npmjs.com/package/group-css-media-queries-loader"&gt;plugin&lt;/a&gt; on NPM to find out more.    &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Please keep in mind that patterns are not usually a one-size-fits-all deal. &lt;/p&gt;

&lt;p&gt;I do love this approach because it is quite minimalist and I have used on projects for two years now.&lt;/p&gt;

&lt;p&gt;However, I am open to learn about your approach in the comments, including suggestions. &lt;/p&gt;

&lt;p&gt;I hope you enjoyed this article, till next time. &lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>scss</category>
    </item>
    <item>
      <title>Solving a medium algorithm challenge step by step — Minimum Number of Platforms Required for a Railway Station</title>
      <dc:creator>Adavize A.</dc:creator>
      <pubDate>Fri, 01 Jul 2022 09:37:23 +0000</pubDate>
      <link>https://forem.com/adavize/solving-a-medium-algorithm-challenge-step-by-step-minimum-number-of-platforms-required-for-a-railway-station-1cpe</link>
      <guid>https://forem.com/adavize/solving-a-medium-algorithm-challenge-step-by-step-minimum-number-of-platforms-required-for-a-railway-station-1cpe</guid>
      <description>&lt;p&gt;Hello 👋🏽, I came across the “Minimum Number of Platforms Required for a Railway” coding challenge and decided to share my solution.&lt;/p&gt;

&lt;p&gt;I provide code implementations in JavaScript and C++ with clear explanations and time complexity analysis in the end. To fully understand this article, it is required that you have a working knowledge of basic programming concepts(variables, control structures, etc.).&lt;/p&gt;

&lt;h2&gt;
  
  
  The Question
&lt;/h2&gt;

&lt;p&gt;Given the arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required for the railway station so that no train waits. &lt;/p&gt;

&lt;p&gt;The provided input is two arrays representing the arrival and departure times of trains that stop.&lt;br&gt;
Note: The time values are in 24hr format.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Arrival = [ 900, 940, 950, 1100, 1500, 1800 ]&lt;br&gt;
Departure = [ 910, 1200, 1120, 1130, 1900, 2000]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Output: 3 (A minimum of 3 platforms are needed so that no train waits)&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation
&lt;/h2&gt;

&lt;p&gt;The question provides arrival and departure times of all trains that pass through a station with separate arrays.&lt;/p&gt;

&lt;p&gt;The data in these arrays are linked by their indexes in these arrays. For example, say train A, owning index “0” of both arrays, arrives at 9:00 and departs at 9:10. There is a waiting period between each arrival and departure. We can assume this allows passengers to disembark and board the train, and by default, there is one platform that all the trains use.&lt;/p&gt;

&lt;p&gt;The problem arises when multiple trains have overlapping wait times, which can cause a block in the single platform, causing the trains to queue. This means that trains ready to depart may be delayed by a waiting train in front of them; therefore, they must wait extra time as they can not jump the queue.&lt;/p&gt;

&lt;p&gt;For example, if train B is ready to depart, and there is a waiting train A in front of it, train B must wait until train A leaves. The goal is to find the minimum number of platforms that won’t result in any delay from overlapping times.&lt;/p&gt;

&lt;p&gt;The illustration below shows how three trains with overlapping times queue using one, two or three platforms.&lt;br&gt;
&lt;a href="https://media.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%2Fmgk5ql84z1xc5g5rqaqd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmgk5ql84z1xc5g5rqaqd.jpg" alt="Illustration of queuing trains"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming the maximum number of trains that wait at a particular time is three, then three platforms are required to ensure that no train waits for another to leave before it can — the needed answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Approach
&lt;/h2&gt;

&lt;p&gt;Since we know that the maximum number of trains present together at the station at a particular time is also the minimum number of platforms required so that no train waits. We can chronologically simulate each train's arrival and departure and record the maximum number of trains present together throughout the simulation.&lt;/p&gt;

&lt;p&gt;During this simulation, we use a virtual queue to represent trains at the station at each moment. The answer will be the maximum length(or size) of the queue encountered during the simulation.&lt;/p&gt;

&lt;p&gt;This solution employs a virtual clock to keep track of the present time during the simulation. To know which trains have supposedly departed the station, we compare the departure times of the waiting trains with the present time.&lt;/p&gt;

&lt;p&gt;If you are familiar with the conventional “queue” data structure, please note that the virtual queue being referred to here is different. It is only a means to store and delete items.&lt;/p&gt;

&lt;p&gt;The list below is a high-level summary of the approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sort the input data in ascending order, according to their arrival times. I.e. the earliest train comes first.&lt;/li&gt;
&lt;li&gt;Create variables to store 

&lt;ol&gt;
&lt;li&gt;The virtual clock,&lt;/li&gt;
&lt;li&gt;The virtual queue and &lt;/li&gt;
&lt;li&gt;The maximum number of waiting trains seen at a particular time.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Loop through the sorted input (see step 1) from the beginning. Each current iteration of the loop represents the arrival of a train.&lt;/li&gt;

&lt;li&gt;When a train arrives, the virtual clock is updated using the arrival time of the newly arrived train, signifying the present moment.&lt;/li&gt;

&lt;li&gt;After updating the virtual clock, we check for supposedly departed trains and remove them from the virtual queue. This is achieved by comparing their departure times with the present time of the clock.&lt;/li&gt;

&lt;li&gt;The newly arrived train is added to the queue, as it is presently at the station.&lt;/li&gt;

&lt;li&gt;Suppose the virtual queue's current length (or size) is greater than any previously seen length, the “max” variable (created in step 2) is updated to this current length.&lt;/li&gt;

&lt;li&gt;The “max” variable is returned as the answer at the end of the simulation (or loop).&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  JavaScript Solution
&lt;/h2&gt;

&lt;p&gt;We begin by converting the input arrays into a single array of objects representing a train's data we will use in our solution to simplify the process. Below is an example of the format.&lt;/p&gt;

&lt;p&gt;i.e &lt;code&gt;{&lt;br&gt;
    arrivedAt: 900,&lt;br&gt;
    departsAt: 910&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The helper function below, “makeTrainsArray”, creates an array of such objects. This helper function also sorts the array according to arrival time because the provided problem input is not guaranteed to be sorted. &lt;/p&gt;

&lt;p&gt;Inputs:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Arrivals = [ 900, 940, 950, 1100, 1500, 1800 ]&lt;br&gt;
Departures = [ 910, 1200, 1120, 1130, 1900, 2000]&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="c1"&gt;// Makes a single trains array, sorted chronologically with their arrival times&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;makeTrainsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;trainsArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;trainsArr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="na"&gt;departsAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Sort data according to arrival time&lt;/span&gt;
    &lt;span class="nx"&gt;trainsArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arrivedAt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;trainsArr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, we write function to find the minimum number of platforms required&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;findMinimumPlatforms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;trains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeTrainsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;virtualClockTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;maxTrainsWaiting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Using a JavaScript set because deleting an item is straightforward, compared to arrays&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;virtualQueue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


    &lt;span class="c1"&gt;// Taking each train sequentially to simulate arrivals&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newlyArrivedTrain&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Update present moment to the time of newly arrived train&lt;/span&gt;
        &lt;span class="nx"&gt;virtualClockTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newlyArrivedTrain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


        &lt;span class="c1"&gt;// Remove supposedly departed trains from the virtual queue…&lt;/span&gt;
        &lt;span class="c1"&gt;// … using the present time.&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;train&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;virtualQueue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;


            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;train&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;departsAt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;virtualClockTime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;virtualQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;


        &lt;span class="c1"&gt;// Add newly arrived train to virtual queue&lt;/span&gt;
        &lt;span class="nx"&gt;virtualQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newlyArrivedTrain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


        &lt;span class="c1"&gt;// Keep track of the maximum number of trains queueing at this particular time&lt;/span&gt;
        &lt;span class="nx"&gt;maxTrainsWaiting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;maxTrainsWaiting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;virtualQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;maxTrainsWaiting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  C++ Solution
&lt;/h2&gt;

&lt;p&gt;There’s an issue with the JavaScript solution. In order to check and remove supposedly departed trains from the virtual queue, all items in the queue are visited, including non-departed trains. This process can be optimised using a “min-heap”.&lt;/p&gt;

&lt;p&gt;A min-heap, also known as a “priority queue”, is a data structure that always keeps a reference to the smallest item in the “heap”.&lt;/p&gt;

&lt;p&gt;The smallest item— the top, can be easily “popped” out of the queue. &lt;/p&gt;

&lt;p&gt;The image below visualises the structure of a min-heap when all departure times from the example are inserted:&lt;br&gt;
&lt;a href="https://media.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%2Fsjsqkeokkelaku6dmoqt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsjsqkeokkelaku6dmoqt.jpg" alt="Illustration of min-heap (priority queue)"&gt;&lt;/a&gt;&lt;br&gt;
(Resources on min-heap data structure are at the end of this article).&lt;/p&gt;

&lt;p&gt;This min-heap structure is not present in JavaScript by default. You’d have to implement a class or use an external library to use it. We will not be doing that in this article. &lt;/p&gt;

&lt;p&gt;However, we can use the priority_queue data type present in C++’s STL— Standard Template Library. This way, we can quickly check for supposedly departed trains and remove them without visiting every item in the queue.&lt;/p&gt;

&lt;p&gt;Below is a C++ implementation of the same solution, but checking for departed trains is done using a min-heap.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="c1"&gt;// The next two imports can be reduced to #include &amp;lt;bits/stdc++.h&amp;gt;, depending on your compiler.&lt;/span&gt;
&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;algorithm&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; // We'll need this for sorting&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;queue&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; // We'll need this for the priority queue (or min heap)&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;TrainData&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;departsAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Helper function for sorting with arrival times&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;compareArrivalTimes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TrainData&lt;/span&gt; &lt;span class="n"&gt;trainA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TrainData&lt;/span&gt; &lt;span class="n"&gt;trainB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trainA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arrivedAt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;trainB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Helper function to make a trains array sorted chronologically with their arrival times&lt;/span&gt;
&lt;span class="n"&gt;TrainData&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;makeTrainsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;TrainData&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;TrainData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="c1"&gt;// Make a new train data using the defined struct&lt;/span&gt;
        &lt;span class="n"&gt;TrainData&lt;/span&gt; &lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arrivedAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departsAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="n"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compareArrivalTimes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, a function to find the minimum function to platforms required&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;findMinimumPlatforms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;TrainData&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;makeTrainsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arrivals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;departures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;virtualClockTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;maxTrainsWaiting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c1"&gt;// Using a priority queue data structure for the virtual queue.&lt;/span&gt;&lt;br&gt;
  &lt;span class="n"&gt;priority_queue&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;virtualQueue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br&gt;
    &lt;span class="c1"&gt;// Update present moment to the time of newly arrived train&lt;/span&gt;&lt;br&gt;
    &lt;span class="n"&gt;virtualClockTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;arrivedAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class="c1"&amp;gt;// Remove supposedly departed trains from the virtual queue by using the present time.&amp;lt;/span&amp;gt;
&amp;lt;span class="k"&amp;gt;while&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;!&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;empty&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;())&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;{&amp;lt;/span&amp;gt;
  &amp;lt;span class="kt"&amp;gt;int&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;departureTime&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;top&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;()&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;*&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;-&amp;lt;/span&amp;gt;&amp;lt;span class="mi"&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;;&amp;lt;/span&amp;gt;
  &amp;lt;span class="k"&amp;gt;if&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;departureTime&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;&amp;amp;lt;&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;virtualClockTime&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;)&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;{&amp;lt;/span&amp;gt;
    &amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;pop&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;();&amp;lt;/span&amp;gt;
  &amp;lt;span class="p"&amp;gt;}&amp;lt;/span&amp;gt; &amp;lt;span class="k"&amp;gt;else&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;{&amp;lt;/span&amp;gt;
    &amp;lt;span class="c1"&amp;gt;// We can break out of the loop here because all departed trains have been removed.&amp;lt;/span&amp;gt;
    &amp;lt;span class="k"&amp;gt;break&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;;&amp;lt;/span&amp;gt;
  &amp;lt;span class="p"&amp;gt;}&amp;lt;/span&amp;gt;

&amp;lt;span class="p"&amp;gt;}&amp;lt;/span&amp;gt;

&amp;lt;span class="c1"&amp;gt;// Add newly arrived train to queue (note we are storing only the time in the priority queue)&amp;lt;/span&amp;gt;
&amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;push&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;trains&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;i&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;].&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;departsAt&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;*&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;-&amp;lt;/span&amp;gt;&amp;lt;span class="mi"&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;);&amp;lt;/span&amp;gt;

&amp;lt;span class="c1"&amp;gt;// Keep track of the maximum number of trains queueing at this particular time&amp;lt;/span&amp;gt;
&amp;lt;span class="n"&amp;gt;maxTrainsWaiting&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;maxTrainsWaiting&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;&amp;amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;size&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;()&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;?&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;maxTrainsWaiting&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;:&amp;lt;/span&amp;gt; &amp;lt;span class="n"&amp;gt;virtualQueue&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class="n"&amp;gt;size&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;();&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c1"&gt;// Free up allocated memory ;)&lt;/span&gt;&lt;br&gt;
  &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;trains&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;maxTrainsWaiting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Analysing The Time Complexity&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, we analyse this solution's time complexity using “big O” notation.&lt;/p&gt;

&lt;p&gt;Here are some things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sorting processes generally perform an O(n * log(n)), and we used a sort function. &lt;/li&gt;
&lt;li&gt;The simulation loop performs an O(n) operation since every item is visited once. Denoting the length of the input as n.&lt;/li&gt;
&lt;li&gt;There is a nested while loop within the simulation loop, denoting the maximum length of the queue as m; this nested loop performs an O(m) operation.&lt;/li&gt;
&lt;li&gt;Inserting and deleting items from a priority queue, in the worst case, will perform an O(log(m)) operation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In time complexity analysis, the big O of the algorithm is that of the worst operation performed within the algorithm.&lt;/p&gt;

&lt;p&gt;At first glance, it seems like the sorting step is the most costly operation, making this an O(n * log(n)) solution.&lt;/p&gt;

&lt;p&gt;Suppose m &amp;gt; log(n), the attention of the time complexity shifts from the sorting process to the simulation loop.&lt;/p&gt;

&lt;p&gt;The simulation loop nests another loop— denoted with O(m). Hence the time complexity of the JavaScript solution is O(n * m).&lt;/p&gt;

&lt;p&gt;The C++ solution performs “delete” operations on the min-heap, which has a time complexity of O(log(m)). We can then say the algorithm's time complexity is O(n * m * log(m)).&lt;/p&gt;

&lt;p&gt;The main difference between the JavaScript C++ solution is that the JavaScript solution is guaranteed to complete all iterations of “m”. The C++ solution can break out of the loop once it has removed all departed trains— using the min-heap, it doesn’t waste time checking non-departed trains. Thus, it is seemingly more efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;When coming up with a brute force solution, it is helpful to determine how you understand the problem, what a working solution is and what would make a working solution. Then you can attempt translating that thought process into code with the help of data structures.&lt;/p&gt;

&lt;p&gt;It is common for algorithm challenges to have multiple solutions. There are other solutions to this problem, including more efficient ones. It is okay if you come up with a different approach to this problem.&lt;/p&gt;

&lt;p&gt;This article was written to help people get comfortable with data structures and algorithms and translate their thought processes into code to arrive at a solution.&lt;/p&gt;

&lt;p&gt;I hope you enjoyed it. Thanks for reading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;To learn more about priority queues:&lt;br&gt;
&lt;a href="https://www.programiz.com/cpp-programming/priority-queue" rel="noopener noreferrer"&gt;https://www.programiz.com/cpp-programming/priority-queue&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can practice your solution against test cases here:&lt;br&gt;
&lt;a href="https://practice.geeksforgeeks.org/problems/minimum-platforms-1587115620/1#" rel="noopener noreferrer"&gt;https://practice.geeksforgeeks.org/problems/minimum-platforms-1587115620/1#&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Big O Notation:&lt;br&gt;
&lt;a href="https://www.doabledanny.com/big-o-notation-in-javascript" rel="noopener noreferrer"&gt;https://www.doabledanny.com/big-o-notation-in-javascript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution files on GitHub:&lt;br&gt;
&lt;a href="https://github.com/adavize0/public-algo/tree/main/minumum%20platforms" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>javascript</category>
      <category>cpp</category>
    </item>
    <item>
      <title>The Purpose of Git and GitHub in Development — A beginner-friendly explanation</title>
      <dc:creator>Adavize A.</dc:creator>
      <pubDate>Sat, 11 Jun 2022 04:40:38 +0000</pubDate>
      <link>https://forem.com/adavize/the-purpose-of-git-and-github-in-development-a-beginner-friendly-explanation-c6m</link>
      <guid>https://forem.com/adavize/the-purpose-of-git-and-github-in-development-a-beginner-friendly-explanation-c6m</guid>
      <description>&lt;p&gt;If you are relatively new to programming, there comes a time when you come across Git and GitHub. This may be when you want to deploy a project on the internet, share your code, collaborate on projects with other developers, help someone else with their code, etc.&lt;/p&gt;

&lt;p&gt;Jumping on a Git tutorial without understanding the purpose of Git can be confusing. In this article, I will explain why tools like Git and GitHub are essential in the software development ecosystem, using beginner-friendly analogies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Life Without Git
&lt;/h2&gt;

&lt;p&gt;Let’s assume you are working on a project using your personal computer. You will have a project folder that contains your code files and configurations on which you have been making changes.&lt;/p&gt;

&lt;p&gt;Now, let us simulate a week’s work:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Monday:&lt;/strong&gt;&lt;br&gt;
You wrote the code for four new features - features A, B, C, and D.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Tuesday:&lt;/strong&gt;&lt;br&gt;
You fixed a bug, bug X.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Wednesday:&lt;/strong&gt;&lt;br&gt;
You removed two features, B and C, because they seemed unnecessary, and you deleted quite a lot of code in the process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thursday:&lt;/strong&gt;&lt;br&gt;
You realise that one of the features you deleted from your code on Thursday, say feature C, is an essential feature, and you need to get it back.&lt;/p&gt;

&lt;p&gt;A possible solution is to rewrite the code, but remember, it was a lot of code, so that would be stressful.&lt;/p&gt;

&lt;p&gt;Let’s assume you made a copy of the files before removal (probably as a precaution). You’d still go through the “stress” of copying the code from the “backup” and merging them with your current work files; this process is one of the reasons why Git exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lastly, on Friday:&lt;/strong&gt;&lt;br&gt;
While testing your code, you realise that the bug you fixed on Tuesday introduced other disturbing bugs, and you wish to undo your “bug fix”. There isn’t much that Ctrl + Z can do to help in this situation.&lt;/p&gt;

&lt;p&gt;Wouldn’t it be nice to have a magical time travel machine in these scenarios? That can easily take us to previous versions of our project, as they were at a specific time? Think of Git as that time travel machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Does Git Do?
&lt;/h2&gt;

&lt;p&gt;Git provides a "version-control system". This means Git helps you manage or control different versions of your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Git Works
&lt;/h2&gt;

&lt;p&gt;Managing your project using Git means Git will keep an eye on files and directories in that project— tracking.&lt;/p&gt;

&lt;p&gt;Git notices the changes made to tracked files in your project. These changes are then “committed” into Git’s history.&lt;/p&gt;

&lt;p&gt;When changes are committed, Git takes a “snapshot” of the files, so it remembers the exact state of the files at that time, just like a photograph.&lt;/p&gt;

&lt;p&gt;You can have as many commits as you work on your project, and when the need arises, you can view or restore your files to a previous commit. Git will give back your files exactly as they were when you made the commit— the required time travel.&lt;/p&gt;

&lt;p&gt;Also, with Git, you can easily switch between different versions of your project, compare and track the changes over time, collaborate with other developers and lots more.&lt;/p&gt;

&lt;p&gt;Here’s an illustration to help you visualise the timeline.&lt;br&gt;
&lt;a href="https://media.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%2Friexrsuywuw7mg02ykq7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Friexrsuywuw7mg02ykq7.jpg" alt="Image visualising activities on the codebase from Monday to Friday"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What about GitHub?
&lt;/h2&gt;

&lt;p&gt;Git has numerous features that help simplify development; another is making collaboration organised.&lt;/p&gt;

&lt;p&gt;Imagine you are working remotely with about ten other developers on the same project. Without Git, there will most likely be a lot of confusion and mishaps.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When multiple people work on the same file, how is this sorted?&lt;/li&gt;
&lt;li&gt;What happens when the file you made changes to gets deleted on someone else’s computer?&lt;/li&gt;
&lt;li&gt;How do you know who made a specific change and when this change was made?&lt;/li&gt;
&lt;li&gt;Most importantly, how is everyone’s contribution combined in the project?.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Will everyone attach their work files in an email and send them to a “manager” who then downloads and sorts it all? And does this hectic process have to be repeated for every little change? Hopefully not.&lt;/p&gt;

&lt;p&gt;As earlier mentioned, Git helps to keep collaboration organised.&lt;/p&gt;

&lt;p&gt;A project being managed with Git is known as a repository, and this is where GitHub comes in.&lt;/p&gt;

&lt;p&gt;GitHub helps to host your project repositories on the internet. Your project files are stored on the internet, making them accessible to remote collaborators.&lt;/p&gt;

&lt;p&gt;Contributors to that project can have a local copy of the project on their computers, make changes on their local copy and “push” those changes back to the online repository. &lt;/p&gt;

&lt;p&gt;With Git and GitHub, changes pushed from several collaborators are easily organised, combined and managed. Everyone with access to the online repository can see these changes and update their local version. Cool right?&lt;/p&gt;

&lt;p&gt;Here’s an illustration to help you visualise:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fp32sa2qat0wpzzpxz8y0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fp32sa2qat0wpzzpxz8y0.jpg" alt="Illustrating collaboration via GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Git and GitHub have many other incredible benefits. I hope you now understand the purpose of Git and GitHub and why they are essential tools in development.&lt;/p&gt;

&lt;p&gt;I should mention that there are other version control systems and hosts for repositories.&lt;/p&gt;

&lt;p&gt;Goodluck learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.to/adavize/learning-git-as-a-beginner-tips-m42"&gt;Learning Git as a beginner - Tips&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>Learning Git as a beginner - Tips</title>
      <dc:creator>Adavize A.</dc:creator>
      <pubDate>Fri, 10 Jun 2022 22:01:24 +0000</pubDate>
      <link>https://forem.com/adavize/learning-git-as-a-beginner-tips-m42</link>
      <guid>https://forem.com/adavize/learning-git-as-a-beginner-tips-m42</guid>
      <description>&lt;p&gt;Learning how to work with a new tool as a beginner could be exciting, frustrating, or a mix of both. The concentration of that mix depends heavily on how you learn it.&lt;/p&gt;

&lt;p&gt;In this article, I will share tips that helped while I was just learning Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understand the why
&lt;/h2&gt;

&lt;p&gt;Knowing the purpose of a version control system such as Git in a development environment will help you understand “what is going on” while learning. When you &lt;strong&gt;"git add"&lt;/strong&gt; a file, what happens?&lt;/p&gt;

&lt;p&gt;Focus on understanding Git itself at the initial stages of learning. Things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What does it mean to commit files?&lt;/li&gt;
&lt;li&gt;When should I tell Git to ignore files?&lt;/li&gt;
&lt;li&gt;What does it mean to &lt;strong&gt;pull&lt;/strong&gt; changes? What are changes?.&lt;/li&gt;
&lt;li&gt;What causes a merge conflict? What is done to resolve this?&lt;/li&gt;
&lt;li&gt;Etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If these terminologies do not make sense to you yet, it is totally okay, just keep an eye out for them while learning.&lt;/p&gt;

&lt;p&gt;See &lt;a href="https://dev.to/adavize/the-purpose-of-git-and-github-in-development-a-beginner-friendly-explanation-c6m"&gt;The Purpose of Git and GitHub in Development — A beginner-friendly explanation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get familiar with the terminal (Console, CLI)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pK9-qrUn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbfn193iu1l5wmi33kpz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pK9-qrUn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbfn193iu1l5wmi33kpz.jpg" alt="illustration of a computer terminal" width="447" height="190"&gt;&lt;/a&gt;&lt;br&gt;
Most people who use computers today are comfortable with using graphical user interfaces. Although there are GUI options for Git, familiarity with the terminal is very helpful for software developers.&lt;br&gt;
When starting out, you do not need to master how to use the terminal like a hacker; a basic understanding is enough.&lt;/p&gt;

&lt;p&gt;Actions such as these can help you get comfortable with the terminal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic file commands, e.g. create and navigate through directories, list files and folders in a directory, copy, move, delete etc.&lt;/li&gt;
&lt;li&gt;Create and open files using the terminal, e.g. create a text file and open it with a text editor&lt;/li&gt;
&lt;li&gt;Whatever feels right to practice with, just don't recursively delete your files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you are comfortable using the terminal, running Git commands shouldn’t be tough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid cramming commands, use a cheat sheet instead
&lt;/h2&gt;

&lt;p&gt;With time and practice, the commands and their respective meanings gets easier to remember.&lt;/p&gt;

&lt;p&gt;PS: There are a few basic commands that are helpful and important to remember, but don't go memorising all of Git's commands.&lt;br&gt;
Using a "cheat sheet" helps— A list of commands with short descriptions for quick reference.&lt;/p&gt;

&lt;p&gt;Also, searching the internet for things you don’t remember isn't a bad idea (we’ll get to this in the next heading).&lt;/p&gt;

&lt;p&gt;Here’s a cheat sheet from GitHub education; please note that you can always make your simplified personal version - &lt;a href="https://education.github.com/git-cheat-sheet-education.pdf"&gt;Git Cheat Sheet&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GIYF
&lt;/h2&gt;

&lt;p&gt;GIYF - “Google Is Your Friend” is a famous phrase in the ecosystem. If your favourite search engine works fine, that’s cool too.&lt;br&gt;
Most bugs and issues you will face are probably somewhere on the internet, with solutions from people who have already overcome them.&lt;br&gt;
It is helpful to dig the internet for answers, and I believe it is okay to look up what you don’t remember.&lt;/p&gt;

&lt;p&gt;Remember to search using phrases of what you are trying to achieve, your error codes and messages etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid getting stuck with a single learning resource
&lt;/h2&gt;

&lt;p&gt;There are tons of learning resources out there. Some are good, and some are not so great.&lt;/p&gt;

&lt;p&gt;You could be learning from books or videos, but wherever you’re learning from, if need be, check for alternatives that help you understand better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask for help
&lt;/h2&gt;

&lt;p&gt;Asking questions while learning helps make learning easier. But before asking I advise searching the internet first.&lt;/p&gt;

&lt;p&gt;You could ask an online tech community, a local tech community, a more experienced friend, a mentor etc. Just be sure to structure your questions in ways that make it easy for people to understand and help out. Note that people have their schedules.&lt;/p&gt;

&lt;p&gt;Here are helpful things to include while asking for help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where you’re coming from&lt;/li&gt;
&lt;li&gt;What you’re trying to achieve&lt;/li&gt;
&lt;li&gt;The problem you’re facing&lt;/li&gt;
&lt;li&gt;Include error codes, error descriptions and other details that can help others understand your error&lt;/li&gt;
&lt;li&gt;Include your attempts to resolve the issue if you’ve tried anything&lt;/li&gt;
&lt;li&gt;Be sure to ask nicely, and leverage the magic words.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;E.g. Hey, I cloned a repository, worked the files and committed my changes. Now when I try to push to the remote repository, I get the error “error here”. Can anyone tell me what’s wrong? Thanks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice
&lt;/h2&gt;

&lt;p&gt;We learn by doing! After taking Git tutorials and lectures, you need to put them into practice to master the knowledge you’ve gained.&lt;/p&gt;

&lt;p&gt;Use Git to manage your personal and real-world projects; this will help you get familiar with the various scenarios that occur when working with Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope you find these tips helpful. May the force be with you &amp;lt;3&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>tips</category>
    </item>
  </channel>
</rss>
