<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Tmegha's blog]]></title><description><![CDATA[I am a fullstack engineer with 5 years of professional experience. As much as I love building, learning about a stack, I also write technical articles on tech a]]></description><link>https://tmegha.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1672945625559/6A1ZIlyNC.jpg</url><title>Tmegha&apos;s blog</title><link>https://tmegha.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 05:34:21 GMT</lastBuildDate><atom:link href="https://tmegha.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Leetcode 365 (2023)]]></title><description><![CDATA[Day 3: 944. Delete Columns to Make Sorted
Hi there, Day 3 is here, unfortunately, had to publish this late due to some personal issues.
So onto our daily leetcode DSA questions with concise solutions, Now to the Question.
You are given an array of n ...]]></description><link>https://tmegha.hashnode.dev/leetcode-365-2023-1</link><guid isPermaLink="true">https://tmegha.hashnode.dev/leetcode-365-2023-1</guid><category><![CDATA[leetcode_365]]></category><category><![CDATA[leetcode-solution]]></category><category><![CDATA[data structures]]></category><category><![CDATA[data structure and algorithms ]]></category><category><![CDATA[algorithms]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Thu, 05 Jan 2023 18:48:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672943709917/27118a6f-48ca-4b0f-b773-b54d32ae637d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Day 3: 944. Delete Columns to Make Sorted</strong></p>
<p>Hi there, Day 3 is here, unfortunately, had to publish this late due to some personal issues.</p>
<p>So onto our daily leetcode DSA questions with concise solutions, Now to the Question.</p>
<p>You are given an array of <code>n</code> strings <code>strs</code>, all of the same length.</p>
<p>The strings can be arranged such that there is one on each line, making a grid. For example, <code>strs = ["abc", "bce", "cae"]</code> can be arranged as:</p>
<pre><code class="lang-plaintext">abc
bce
cae
</code></pre>
<p>You want to <strong>delete</strong> the columns that are <strong>not sorted lexicographically</strong>. In the above example (0-indexed), columns 0 (<code>'a'</code>, <code>'b'</code>, <code>'c'</code>) and 2 (<code>'c'</code>, <code>'e'</code>, <code>'e'</code>) are sorted while column 1 (<code>'b'</code>, <code>'c'</code>, <code>'a'</code>) is not, so you would delete column 1.</p>
<p>Return <em>the number of columns that you will delete</em>.</p>
<pre><code class="lang-plaintext">Input: strs = ["cba","daf","ghi"]
Output: 1
Explanation: The grid looks as follows:
  cba
  daf
  ghi
Columns 0 and 2 are sorted, but column 1 is not, so you only need to delete 1 column.
</code></pre>
<pre><code class="lang-plaintext">Input: strs = ["a","b"]
Output: 0
Explanation: The grid looks as follows:
  a
  b
Column 0 is the only column and is sorted, so you will not delete any columns.
</code></pre>
<pre><code class="lang-plaintext">Input: strs = ["zyx","wvu","tsr"]
Output: 3
Explanation: The grid looks as follows:
  zyx
  wvu
  tsr
All 3 columns are not sorted, so you will delete all 3.
</code></pre>
<p>with constraints given as follows</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><p><code>n == strs.length</code></p>
</li>
<li><p><code>1 &lt;= n &lt;= 100</code></p>
</li>
<li><p><code>1 &lt;= strs[i].length &lt;= 1000</code></p>
</li>
<li><p><code>strs[i]</code> consists of lowercase English letters.</p>
</li>
</ul>
<p>Approach:</p>
<p>Given an array of alphabets that should be arranged column-wise to give us an idea of which column is not sorted lexicographically.A lexicographical order simply means an <strong>ordered set</strong>. Also, take note that the solution is to get the column that is not sorted to be deleted.</p>
<p>Typically since the array has to be represented in column format, the first column is initialized to zero to keep track of the number of deletions that need to be made and we are going to iterate through individual columns to get one that is not sorted.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@param <span class="hljs-type">{string[]}</span> <span class="hljs-variable">strs</span></span>
 * <span class="hljs-doctag">@return <span class="hljs-type">{number}</span></span>
 */</span>
<span class="hljs-keyword">var</span> minDeletionSize = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">strs</span>) </span>{
<span class="hljs-comment">// initialize the count to be 0</span>
  <span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>;
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; strs[<span class="hljs-number">0</span>].length; i++) {
    <span class="hljs-keyword">let</span> m = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> j = <span class="hljs-number">0</span>; j &lt; strs.length<span class="hljs-number">-1</span>; j++) {
<span class="hljs-comment">// the charCodeAt method In JavaScript returns an integer btwn 0 and 65535</span>
      <span class="hljs-keyword">if</span> (strs[j].charCodeAt(i) &gt; strs[j+<span class="hljs-number">1</span>].charCodeAt(i))
        m++;
    }
    <span class="hljs-keyword">if</span>(m !== <span class="hljs-number">0</span>)
      count++;
  }
  <span class="hljs-keyword">return</span> count;
};
</code></pre>
<p>from the code above, It shows that you can actually <strong>delete</strong> the columns that are <strong>not sorted lexicographically, in which the function gives you a number as an output</strong></p>
<p>So that's all for <strong>Day 3</strong>, Your comments and optimized solutions to questions are well appreciated. Thank you for reading..</p>
]]></content:encoded></item><item><title><![CDATA[Leetcode 365 (2023)]]></title><description><![CDATA[Day 2: 520. Detect Capital Using JavaScript
Hi there, we continue with our daily leetcode DSA questions,
And now to Day 2 Question on Detect capital using JavaScript
We define the usage of capitals in a word to be right when one of the following case...]]></description><link>https://tmegha.hashnode.dev/leetcode-365-2023</link><guid isPermaLink="true">https://tmegha.hashnode.dev/leetcode-365-2023</guid><category><![CDATA[data structures]]></category><category><![CDATA[data structure and algorithms ]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[leetcode-solution]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Tue, 03 Jan 2023 21:31:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672777287969/c322b3e7-33d5-4ccc-a79d-50f59ce0753b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-day-2-520-detect-capital-using-javascript">Day 2: 520. Detect Capital Using JavaScript</h3>
<p>Hi there, we continue with our daily leetcode DSA questions,</p>
<p>And now to Day 2 Question on Detect capital using JavaScript</p>
<p>We define the usage of capitals in a word to be right when one of the following cases holds:</p>
<ul>
<li><p>All letters in this word are capitals, like <code>"USA"</code>.</p>
</li>
<li><p>All letters in this word are not capitals, like <code>"leetcode"</code>.</p>
</li>
<li><p>Only the first letter in this word is <strong>capital</strong>, like <code>"Google"</code>.</p>
</li>
</ul>
<p>Given a string <code>word</code>, return <code>true</code> if the usage of capitals in it is right.</p>
<p>Examples of test cases are given</p>
<pre><code class="lang-plaintext">Input: word = "USA"
Output: true
</code></pre>
<pre><code class="lang-plaintext">Input: word = "FlaG"
Output: false
</code></pre>
<ul>
<li><p><code>1 &lt;= word.length &lt;= 100</code></p>
</li>
<li><p><code>word</code> consists of lowercase and uppercase English letters.</p>
<p>  Approach I:</p>
<p>  The method of regular expression(Regex) can be implemented to show if a word has all capital letters, small letters and if the first letter of the word in capital letters.</p>
<p>  Regex : Regular expressions are <strong>patterns used to match character combinations in strings.</strong> The regular pattern is defined from the question.The JavaScript code is shown simplify the cases of all capital letters, all small letters and the first word being capital letter</p>
<pre><code class="lang-javascript">  <span class="hljs-comment">/**
   * <span class="hljs-doctag">@param <span class="hljs-type">{string}</span> <span class="hljs-variable">word</span></span>
   * <span class="hljs-doctag">@return <span class="hljs-type">{boolean}</span></span>
   */</span>
  <span class="hljs-keyword">let</span> detectCapitalUse = <span class="hljs-function">(<span class="hljs-params">word</span>) =&gt;</span> {
  <span class="hljs-comment">//returns all capital letters, small letter or the first letter being capital letter</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[A-Z]+$|^[a-z]+$|^[A-Z][a-z]+$/</span>.test(word);
  };
</code></pre>
<p>  The function above returns a boolean indicating if the capitalization in the given word holds true. Just like that, you can determine the boolean value from the Regex format that applies to different test cases.</p>
</li>
<li><p>Approach II:</p>
</li>
<li><p>This makes use of the substring() function in JavaScript which extracts part of a string and outputs a new string, how does this string extract apply to the question?</p>
</li>
<li><p>See below</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> detectCapitalUse = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">word</span>) </span>{
    <span class="hljs-keyword">return</span> (word.substr(<span class="hljs-number">1</span>).toLowerCase() == word.substr(<span class="hljs-number">1</span>) || word.toUpperCase() == word)
};
</code></pre>
<p>Thank you for reading, I'll see you on Day 3.</p>
]]></content:encoded></item><item><title><![CDATA[Leetcode 365 (2023)]]></title><description><![CDATA[Hi there, I am starting the year, publishing optimized solutions to leetcode DSA questions, ranging from Easy, Medium to Hard.
Now to the Day 1 Question on Word patterns
Given a pattern and a string s, find if s follows the same pattern.
Here follow ...]]></description><link>https://tmegha.hashnode.dev/leetcode-365-2023-javascript</link><guid isPermaLink="true">https://tmegha.hashnode.dev/leetcode-365-2023-javascript</guid><category><![CDATA[data structures]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[leetcode-solution]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Mon, 02 Jan 2023 22:46:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672728355911/839f9464-d3e4-41f8-b3fe-c6a4136b4b70.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi there, I am starting the year, publishing optimized solutions to leetcode DSA questions, ranging from Easy, Medium to Hard.</p>
<p>Now to the Day 1 Question on Word patterns</p>
<p>Given a <code>pattern</code> and a string <code>s</code>, find if <code>s</code> follows the same pattern.</p>
<p>Here <strong>follow</strong> means a full match, such that there is a bijection between a letter in <code>pattern</code> and a <strong>non-empty</strong> word in <code>s</code>.</p>
<p>Example 1:</p>
<pre><code class="lang-plaintext">Input: pattern = "abba", s = "dog cat cat dog"
Output: true
</code></pre>
<p>Example 2:</p>
<pre><code class="lang-plaintext">Input: pattern = "abba", s = "dog cat cat fish"
Output: false
</code></pre>
<p>Example 3:</p>
<pre><code class="lang-plaintext">Input: pattern = "aaaa", s = "dog cat cat dog"
Output: false
</code></pre>
<p>Contraints given :</p>
<ul>
<li><p><code>1 &lt;= pattern.length &lt;= 300</code></p>
</li>
<li><p><code>pattern</code> contains only lowercase English letters.</p>
</li>
<li><p><code>1 &lt;= s.length &lt;= 3000</code></p>
</li>
<li><p><code>s</code> contains only lowercase English letters and spaces <code>' '</code>.</p>
</li>
<li><p><code>s</code> <strong>does not contain</strong> any leading or trailing spaces.</p>
</li>
<li><p>All the words <code>s</code> are separated by a <strong>single space</strong>.</p>
<p>  Now let's get started with the solution</p>
</li>
</ul>
<p>There's actually a pattern of a string s, to follow, and the logic revolves around if the string follows that particular pattern, The examples above clearly show the pattern which evaluates to a truism and also otherwise.</p>
<p>The pattern itself can be compared to an array of items in this case we are referring to an array of strings(words) that coincides with the pattern initially given</p>
<p>JavaScript method like split and the strict equality operator is prioritized here, to give the correct solution</p>
<p><strong>Split method</strong>: this method splits a string into an array of substrings, looking at the examples, that's what is playing out looking at it logically. For further reading on the JavaScript Split method, click <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split">here</a></p>
<p><strong>Strict equality operator (===)</strong>: This operator compares two operands, It strictly checks if two operands are the same returning a boolean value. Here the pattern and the array of words are compared.</p>
<p>The code is given below</p>
<pre><code class="lang-javascript"><span class="hljs-comment">/**
 * <span class="hljs-doctag">@param <span class="hljs-type">{string}</span> <span class="hljs-variable">pattern</span></span>
 * <span class="hljs-doctag">@param <span class="hljs-type">{string}</span> <span class="hljs-variable">s</span></span>
 * <span class="hljs-doctag">@return <span class="hljs-type">{boolean}</span></span>
 */</span>
<span class="hljs-keyword">var</span> wordPattern = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">pattern, s</span>) </span>{
 <span class="hljs-comment">// split function being used here </span>
    <span class="hljs-keyword">const</span> arr = s.split(<span class="hljs-string">" "</span>);
    <span class="hljs-keyword">if</span> (pattern.length !== arr.length) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }
<span class="hljs-comment">// looping through the array</span>
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; pattern.length; i++) {
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> j = i + <span class="hljs-number">1</span>; j &lt; pattern.length; j++) {
<span class="hljs-comment">// comparing the pattern and strings,s of array</span>
            <span class="hljs-keyword">if</span> (!(pattern[i] === pattern[j]) === (arr[i] === arr[j])) {
                <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
            }
        }
    }
    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
</code></pre>
<p>The code above shows the concise solution to the word pattern problem with the Time complexity of the function being 0(n).</p>
<p>Thanks for reading, Your views are highly welcomed. Stick with me till Day 2</p>
]]></content:encoded></item><item><title><![CDATA[392: Is Subsequence (Using Javascript)]]></title><description><![CDATA[Hello everyone, my goal to solve DSA questions by giving optimal solutions with detailed explanations will continue with various platforms including Leetcode,I already have a series on hackerrank you could check that out as well.
Now to the Problem w...]]></description><link>https://tmegha.hashnode.dev/392-is-subsequence-using-javascript</link><guid isPermaLink="true">https://tmegha.hashnode.dev/392-is-subsequence-using-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[hackathon]]></category><category><![CDATA[data structures]]></category><category><![CDATA[algorithms]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Thu, 14 Apr 2022 11:15:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1649931168181/aAo-A1yyp.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone, my goal to solve DSA questions by giving optimal solutions with detailed explanations will continue with various platforms including Leetcode,I already have a series on hackerrank you could check that out as well.
Now to the Problem we have at hand
 "Is Subsequence"</p>
<p>Problem: 
Given two strings <strong>s</strong> and <strong>t</strong>, return true if <strong>s</strong> is a subsequence of <strong>t</strong>, or false otherwise.</p>
<p>A <strong>subsequence</strong> of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).</p>
<p>Example 1:</p>
<p><strong>Input: s = "abc", t = "ahbgdc"</strong>
<strong>Output: true</strong></p>
<p>Example 2:</p>
<p><strong>Input: s = "axc", t = "ahbgdc"</strong>
<strong>Output: false</strong></p>
<p>Constraints:</p>
<ul>
<li>0 &lt;= <strong>s.length</strong> &lt;= 100</li>
<li>0 &lt;=<strong> t.length</strong> &lt;= 104
<strong>s</strong> and <strong>t</strong> consist only of lowercase English letters.</li>
</ul>
<p><strong>Follow up:</strong> Suppose there are lots of incoming <strong>s</strong>, say <strong>s1</strong>, <strong>s2</strong>, ..., <strong>sk</strong> where <strong>k &gt;= 109,</strong> and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code? </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649934235214/JC8pI7dR7.gif" alt="lets do this.gif" /></p>
<p>Solution:
From the problem above, It is understood that there's a sequence that can be in form of an array, and a subsequence will be formed from the sequence. We'll use Pseudocodes to find a clearer analogy of the process </p>
<p><strong>Pseudocode:</strong></p>
<ol>
<li><p>Initialize the subsequence(s) to be zero(0).</p>
</li>
<li><p>Use Comparison operators in Conditional statements to compare values (check the array size).</p>
</li>
<li><p>loop through the array index to check if a subsequence is true for all elements.</p>
</li>
<li><p>Compare using a <strong>triple equals(===)</strong> to see if the <strong>s</strong> value are of similar types or not.</p>
</li>
<li><p>Return the subsequence equivalent to the length of the <strong>s</strong> string( Boolean value: True)</p>
</li>
</ol>
<p>JavaScript Code:</p>
<pre><code><span class="hljs-keyword">var</span> isSubsequence <span class="hljs-operator">=</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">s, t</span>) </span>{
    <span class="hljs-comment">// initialise the subsequence to be 0</span>
    let subsequence <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    <span class="hljs-comment">// use comparison operator to check the size of the strings 't' and 's'</span>
    <span class="hljs-keyword">if</span> (s.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> t.<span class="hljs-built_in">length</span>) 
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    <span class="hljs-comment">//loop through the array index to check if a subsequence is true for all elements</span>
    <span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> t.<span class="hljs-built_in">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {
        <span class="hljs-comment">// compare using a triple equals to see if the value are of similar types or not</span>
        <span class="hljs-keyword">if</span> (s[subsequence] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> t[i]){
        subsequence<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;
    }
   }
    <span class="hljs-keyword">return</span> subsequence <span class="hljs-operator">=</span><span class="hljs-operator">=</span> s.<span class="hljs-built_in">length</span>;
};
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649934643562/DzJl52Oxa.gif" alt="quite simple.gif" /></p>
<p>Definitely, there are other ways in finding Optimal solutions to this problem.Array methods like slice(), Filter() can also be implemented to achieve great solutions.
Let me know what you think about the solution to this problem and ways to make it better.
Follow me for more DSA concepts and Step by Step Solutions to Problems.</p>
<p>Thank you.</p>
]]></content:encoded></item><item><title><![CDATA[Compare the Triplets]]></title><description><![CDATA[Problem Statement
Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.
The rating for Alice's challeng...]]></description><link>https://tmegha.hashnode.dev/compare-the-triplets</link><guid isPermaLink="true">https://tmegha.hashnode.dev/compare-the-triplets</guid><category><![CDATA[algorithms]]></category><category><![CDATA[data structures]]></category><category><![CDATA[hackathon]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Mon, 11 Apr 2022 10:11:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1649611657536/f6pFL0VLQ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Problem Statement</strong></p>
<p>Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.</p>
<p>The rating for Alice's challenge is the triplet a = <strong>(a[0], a[1], a[2])</strong>, and the rating for Bob's challenge is the triplet b = <strong>(b[0], b[1], b[2])</strong>.</p>
<p>The task is to find their comparison points by comparing a[0] with b[0], a[1] with b[1], and a[2] with b[2].</p>
<ul>
<li>If <strong>a[i] &gt; b[i]</strong>, then Alice is awarded 1 point.</li>
<li>If <strong>a[i] &lt; b[i]</strong>, then Bob is awarded 1 point.</li>
<li>If <strong>a[i] = b[i]</strong>, then neither person receives a point.
Comparison points are the total points a person earned.</li>
</ul>
<p>Given <strong>a</strong> and <strong>b</strong>, determine their respective comparison points.</p>
<p>Example</p>
<p><strong>a = [1, 2, 3]
b = [3, 2, 1]</strong></p>
<ul>
<li>For elements <em>0</em>, Bob is awarded a point because a[0] .</li>
<li>For the equal elements a[1] and b[1], no points are earned.</li>
<li>Finally, for elements 2, a[2] &gt; b[2] so Alice receives a point.
The return array is [1, 1] with Alice's score first and Bob's second.</li>
</ul>
<p><strong>Function Description</strong></p>
<p>Complete the function compareTriplets in the editor below.</p>
<p>compareTriplets has the following parameter(s):</p>
<ul>
<li>int a[3]: Alice's challenge rating</li>
<li>int b[3]: Bob's challenge rating
Return</li>
<li>int[2]: Alice's score is in the first position, and Bob's score is in the second.</li>
</ul>
<p><strong>Input Format</strong></p>
<p>The first line contains 3 space-separated integers, a[0], a[1], and a[2], the respective values in triplet a.
The second line contains 3 space-separated integers, b[0], b[1], and b[2], the respective values in triplet b.</p>
<p><strong>Constraints</strong></p>
<ul>
<li>1 ≤ a[i] ≤ 100</li>
<li>1 ≤ b[i] ≤ 100</li>
</ul>
<p><strong>Sample Input 0</strong></p>
<p>5 6 7</p>
<p>3 6 10</p>
<p><strong>Sample Output 0</strong></p>
<p>1, 1</p>
<p><strong>Explanation 0</strong></p>
<p>In this example:</p>
<ul>
<li>a = (a[0], a[1], a[2]) = (5,6,7)</li>
<li>b = (b[0], b[1], b[2]) = (3,6,10)</li>
</ul>
<p>Now, let's compare each individual score:</p>
<ul>
<li>a[0] &gt; b[0], so Alice receives 1 point.</li>
<li>a[1] &gt; b[1], so nobody receives a point.</li>
<li>a[2] &lt; b[2], so Bob receives 1 point.</li>
</ul>
<p>Alice's comparison score is 1 and Bob's comparison score is 1. Thus, we return the array [1,1],</p>
<p><strong>Sample Input 1</strong></p>
<p>17 28 30</p>
<p>99 16 8</p>
<p><strong>Sample Output 1</strong></p>
<p>2 1</p>
<p><strong>Explanation 1</strong></p>
<p>Comparing the 0th elements, <strong>17 &lt; 99</strong>  so Bob receives a point.
Comparing the 1st and 2nd elements, <strong>28 &gt; 16 </strong>  and <strong>30 &gt; 8</strong> so Alice receives two points.
The return array is <strong>[2,1]</strong>.</p>
<p><strong>Solution (using Javascript)</strong></p>
<p>In order to solve this, let's have a <strong>Pseudocode</strong> showing the process on how to actualize the final solution. 
Pseudocode is an informal way of presenting a programming solution. 
<strong>Pseudocode:</strong></p>
<ol>
<li>Initialize Alice and bob score to zero.</li>
<li>loop through both arrays (Alice and Bob) and use conditionals to show Alice or Bob ratings</li>
<li>Do a comparison of both ratings individually for every loop.</li>
<li>After looping, use the comparison keyword (or any you wish to use) to return the comparison array in the format [x,y]. </li>
</ol>
<p>code snippet ( using Javascript)</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">compareTriplets</span>(<span class="hljs-params">a, b</span>) </span>{
 <span class="hljs-comment">// initialize the ratings (Alice and Bob score)</span>
    let aScore <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    let bScore <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
  <span class="hljs-comment">//loop through the arrays</span>
    <span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> <span class="hljs-number">3</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>){
   <span class="hljs-comment">// compare using conditionals (if..else)</span>
    <span class="hljs-keyword">if</span> (a[i] <span class="hljs-operator">&gt;</span> b[i]) {
        aScore <span class="hljs-operator">=</span> aScore <span class="hljs-operator">+</span> <span class="hljs-number">1</span>;
 }  <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (a[i] <span class="hljs-operator">&lt;</span> b[i]) {
        bScore <span class="hljs-operator">=</span> bScore <span class="hljs-operator">+</span> <span class="hljs-number">1</span>;
    } <span class="hljs-keyword">else</span> {
        (a[i] <span class="hljs-operator">=</span><span class="hljs-operator">=</span> b[i]);
        <span class="hljs-number">0</span>;
        }     
    }
    const comparison <span class="hljs-operator">=</span> [aScore, bScore];
    <span class="hljs-keyword">return</span> comparison;    
}
</code></pre><p>It is observed that the solution can be solved in some other ways but considering using the loops and the conditional statement is of the essence. We continue with this warmup series on hackerrank as I walk you through easy ways of providing solutions to complex algorithms using Javascript. I will like to read your comments and better solutions. Thank you.</p>
]]></content:encoded></item><item><title><![CDATA[Developer stories]]></title><description><![CDATA[I will be updating some of my developer stories soon...Thanks]]></description><link>https://tmegha.hashnode.dev/developer-stories</link><guid isPermaLink="true">https://tmegha.hashnode.dev/developer-stories</guid><category><![CDATA[Developer]]></category><category><![CDATA[Story]]></category><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Sun, 01 Aug 2021 21:38:05 GMT</pubDate><content:encoded><![CDATA[<p>I will be updating some of my developer stories soon...Thanks</p>
]]></content:encoded></item><item><title><![CDATA[First time on Hashnode]]></title><description><![CDATA[hi there,
I am a Front end Developer with experiences in JavaScript, React, node, a little bit of Angular  and a Mobile Application Developer mainly Flutter/Dart
Connect with me, I have interesting stuffs to share with this great community and to lea...]]></description><link>https://tmegha.hashnode.dev/first-time-on-hashnode</link><guid isPermaLink="true">https://tmegha.hashnode.dev/first-time-on-hashnode</guid><dc:creator><![CDATA[Akinmegha Temitope Samuel]]></dc:creator><pubDate>Thu, 08 Oct 2020 12:56:57 GMT</pubDate><content:encoded><![CDATA[<p>hi there,
I am a Front end Developer with experiences in JavaScript, React, node, a little bit of Angular  and a Mobile Application Developer mainly Flutter/Dart
Connect with me, I have interesting stuffs to share with this great community and to learn as well.</p>
]]></content:encoded></item></channel></rss>