<?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: Ezekiel nwuguru</title>
    <description>The latest articles on DEV Community by Ezekiel nwuguru (@eazylink).</description>
    <link>https://dev.to/eazylink</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%2F918750%2F1ae19e27-3a87-47f2-aee7-3f08383fdf9e.png</url>
      <title>DEV Community: Ezekiel nwuguru</title>
      <link>https://dev.to/eazylink</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eazylink"/>
    <language>en</language>
    <item>
      <title>DAY 10: VALID NUMBER</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Sat, 01 Oct 2022 11:52:44 +0000</pubDate>
      <link>https://dev.to/eazylink/day-10-valid-number-4m28</link>
      <guid>https://dev.to/eazylink/day-10-valid-number-4m28</guid>
      <description>&lt;p&gt;Hey! is day 10 of 10 days coding challenge with I4G. Today's task was to check if a given string is a valid number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Understanding of the problem:&lt;/strong&gt; The task here is to validate that an input is a valid number. A valid number can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A decimal number or an integer.&lt;/li&gt;
&lt;li&gt;(Optional) An 'e' or 'E', followed by an integer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A decimal number can be split up into these components (in order):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;(Optional) A sign character (either '+' or '-').&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One of the following formats:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One or more digits, followed by a dot '.'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One or more digits, followed by a dot '.', followed by one or more digits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A dot '.', followed by one or more digits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An integer can be split up into these components (in order):&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(Optional) A sign character (either '+' or '-').&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One or more digits.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**Solution: **To solve this I employed two java library: regex matcher and regex pattern. The regex matcher check if a given input matches a given pattern. It returns true if it matches and false if it does not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;import regex matcher and regex pattern from java util library&lt;/li&gt;
&lt;li&gt;Trim the given string to remove white spaces and store it in the original string&lt;/li&gt;
&lt;li&gt;Check if string is empty, if so, return false.&lt;/li&gt;
&lt;li&gt;Instantiate the pattern class and declare the required pattern&lt;/li&gt;
&lt;li&gt;Instantiate the Matcher class and check if the string matches the given pattern.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;checkout my code here: &lt;a href="https://leetcode.com/problems/valid-number/submissions/812626535/"&gt;https://leetcode.com/problems/valid-number/submissions/812626535/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codereview</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>DAY 9: Merge k Sorted Lists</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Thu, 29 Sep 2022 13:57:26 +0000</pubDate>
      <link>https://dev.to/eazylink/day-9-merge-k-sorted-lists-16cp</link>
      <guid>https://dev.to/eazylink/day-9-merge-k-sorted-lists-16cp</guid>
      <description>&lt;p&gt;Hey! It's day 9 of 10days coding challenge with I4G. Today's task was to write a code that can merge k sorted lists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Understanding of problem: **The task here requires us to merge k sorted lists into one. Each of the list is already sorted but needs to be merged into a single sorted list.&lt;br&gt;
**Solution&lt;/strong&gt;: Since each list is already sorted, the problem is easier to tackle. There are several approaches to this problem such as divide and conquer, merging the list one by one, comparing each list one by one, using brute force and using priority queue. &lt;br&gt;
In my own solution here, I used priority queue. The node of each list was compared, and the minimum node was added to the queue, until the queue was not empty. Then the minimum node was extracted and stored in our result list. And the result list is return.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a priority queue.&lt;/li&gt;
&lt;li&gt;Add the first node from all the lists into the priority queue.&lt;/li&gt;
&lt;li&gt;Loop until the priority queue is not empty&lt;/li&gt;
&lt;li&gt;Get the minimum node from the queue and add it to our result list.&lt;/li&gt;
&lt;li&gt;Add the next node (if present) from the extracted node list.&lt;/li&gt;
&lt;li&gt;Return the resultant list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout the full code here: &lt;a href="https://leetcode.com/submissions/detail/810988090/"&gt;https://leetcode.com/submissions/detail/810988090/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>DAY 08: Combine two tables</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Wed, 28 Sep 2022 22:23:26 +0000</pubDate>
      <link>https://dev.to/eazylink/day-08-combine-two-tables-39l7</link>
      <guid>https://dev.to/eazylink/day-08-combine-two-tables-39l7</guid>
      <description>&lt;p&gt;Hey! it's day 8 of 10 days coding challenge with I4G. Today's task was to write an SQL code to combine two tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Understanding of problem:&lt;/strong&gt; The task here requires combine two tables in an SQL. The first table Person contains the first and last name while the second table contains the address of the person. So, it is required that the two tables be combined such that a single table with the person's name and address is obtained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; To be able to access a single person's data in both table, a personal id assigned to each table must be the same. To fetch the detail, we simply select the names from the first table and use LEFT JOIN to combine it with the address in the second table where both personal id is the same. If no matching details is found a null is returned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Algorithm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select first and last name from the Person table&lt;/li&gt;
&lt;li&gt;Select city and state from the Address table&lt;/li&gt;
&lt;li&gt;Condition: personal id in both table must be same&lt;/li&gt;
&lt;li&gt;use left join to combine the address with the names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout the full code here: Combine Two Tables - LeetCode &lt;a href="https://leetcode.com/problems/combine-two-tables/submissions/"&gt;https://leetcode.com/problems/combine-two-tables/submissions/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
      <category>codepen</category>
    </item>
    <item>
      <title>DAY 7: UTF-8-VALIDATION</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Tue, 27 Sep 2022 21:37:46 +0000</pubDate>
      <link>https://dev.to/eazylink/day-7-utf-8-validation-5fek</link>
      <guid>https://dev.to/eazylink/day-7-utf-8-validation-5fek</guid>
      <description>&lt;p&gt;Hey! It's day 7 of 10 days coding challenge with I4G. Today's task was to write a code that validates a utf-8 code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Understanding of problem:&lt;/strong&gt; The problem here is to validate a utf-8 character. a utf-8 character has the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A valid UTF-8 character can be 1 - 4 bytes long.&lt;/li&gt;
&lt;li&gt;For a 1-byte character, the first bit is a 0, followed by its unicode.&lt;/li&gt;
&lt;li&gt;For an n-bytes character, the first n-bits are all ones, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.&lt;/li&gt;
&lt;li&gt;The input given would be an array of integers containing the data. We have to return if the data in the array represents a valid UTF-8 encoding. The important thing to note here is that the array doesn't contain data for just a single character. As can be seen from the first example, the array can contain data for multiple characters all of which can be valid UTF-8 characters and hence the charset represented by the array is valid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; To achieve this task, I used bit manipulation. A right shift if performed on the to check it's results for either 1 byte, 2 byte, 3 bytes or 4 bytes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declare two integer variables: count, i&lt;/li&gt;
&lt;li&gt;Set count = 0;&lt;/li&gt;
&lt;li&gt;Using for loop iterate through the array of integers with condition; i = 0, i &amp;lt; data.length&lt;/li&gt;
&lt;li&gt;perform bitwise shift and compare to the features of utf-8 code&lt;/li&gt;
&lt;li&gt;Return true if condition is met or false if otherwise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout the code here: &lt;a href="https://leetcode.com/problems/utf-8-validation/submissions/"&gt;https://leetcode.com/problems/utf-8-validation/submissions/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
    </item>
    <item>
      <title>DAY 6: FIZZ-BUZZ-MULTITHREADED</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Mon, 26 Sep 2022 22:43:03 +0000</pubDate>
      <link>https://dev.to/eazylink/day-6-fizz-buzz-multithreaded-54f9</link>
      <guid>https://dev.to/eazylink/day-6-fizz-buzz-multithreaded-54f9</guid>
      <description>&lt;p&gt;Hey! it's day 6 of 10 days of coding challenge with I4G. Today's task was to write a code that executes fizz buzz multitreaded output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Understanding of the problem:&lt;/strong&gt; The first approach was to understand the task and the constraint attached. Here we writing a code that takes in an integer and prints fizz if the number is divisible by 3, Buzz if the number is divisible by 5, FizzBuzz if the number is divisible by both 3 and 5 or print out the number meets none of the above condition. &lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; To achieve this, we need another that will be used to iterate through the given integer. For each iteration the conditions above are tested and the function that meet the condition is executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;initialize an integer count to 1&lt;/li&gt;
&lt;li&gt;Set a while loop for each function with condition: count &amp;lt; n (the given integer)&lt;/li&gt;
&lt;li&gt;If count is divisible by 3 but not by 5, call the printFizz function&lt;/li&gt;
&lt;li&gt;If count is divisible by 5 but not by 3, call the printBuzz function&lt;/li&gt;
&lt;li&gt;If count is divisible by both 3 and 5 call the printFizzBuzz function&lt;/li&gt;
&lt;li&gt;If count is not divisible by both 3 and 5, call the printNumber function&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;checkout the code here: &lt;a href="https://leetcode.com/problems/fizz-buzz-multithreaded/submissions/"&gt;https://leetcode.com/problems/fizz-buzz-multithreaded/submissions/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
    </item>
    <item>
      <title>DAY 5: Sort characters by frequency</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Sun, 25 Sep 2022 21:56:46 +0000</pubDate>
      <link>https://dev.to/eazylink/day-5-sort-characters-by-frequency-2p26</link>
      <guid>https://dev.to/eazylink/day-5-sort-characters-by-frequency-2p26</guid>
      <description>&lt;p&gt;Hey! It's day 5 of 10 days coding challenge with I4G. Today's challenge was to write a code that sorts characters by frequency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought Process:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Understanding of problem:&lt;/strong&gt; The problem here is to write a code that checks through a string and sorts each character based on their frequency of occurrence &lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; In order to achieve this, I utilized some java classes such as HashMap and StringBuilder. The HashMap is java classes uses the Map interface to store key pair values. In this task I used it to iterate through the given string and store each character and its count in a Map. The character map was then sorted based on frequency and then the string builder was used to build the result back to a string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Instantiate the string builder to builder&lt;/li&gt;
&lt;li&gt;Instantiate the HashMap using the Map interface to charMap as a key pair of Character and Integer&lt;/li&gt;
&lt;li&gt;User for loop to traverse through the string and store it in the charMap&lt;/li&gt;
&lt;li&gt;Sort the character map for each key-value pairs&lt;/li&gt;
&lt;li&gt;Using another for loop iterate through the key-value pair and append to the string builder.&lt;/li&gt;
&lt;li&gt;Return the builder in string format&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Checkout the code here: &lt;a href="https://leetcode.com/submissions/detail/808336602/"&gt;https://leetcode.com/submissions/detail/808336602/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
    </item>
    <item>
      <title>DAY 4: Print in order</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Sat, 24 Sep 2022 08:09:17 +0000</pubDate>
      <link>https://dev.to/eazylink/day-4-print-in-order-4fhn</link>
      <guid>https://dev.to/eazylink/day-4-print-in-order-4fhn</guid>
      <description>&lt;p&gt;Hey! It's day 4 of I4G 10 days of coding challenge. Today's task was to implement a code that prints in order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thought process:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Understanding of problem:&lt;/strong&gt; My first approach in solving this challenge was to understand the problem. Understanding of the problem paved way for me to brainstorm on possible solutions. The way an operating system schedules a thread varies; we cannot predict the order in which the thread can be executed. The task here is to modify a code such that the first thread is always executed first, the second executed second and so on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; To achieve this, I utilized one of the Java classes called Semaphore. Semaphore helps to restrict the number of threads that can access some (physical or logical) resource. The Semaphore class maintains a set of permits. It utilizes the acquire() method to block further executions until a permit is available. It uses the release() method to give a permit, thus releasing a potentially blocking acquirer. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Create two instances of the Semaphore class: semaphore1 and semaphore2&lt;/li&gt;
&lt;li&gt;Add semaphore1.release() to the end of the first thread&lt;/li&gt;
&lt;li&gt;Add semaphore1.acquire() to the beginning of the second thread&lt;/li&gt;
&lt;li&gt;Add semaphore2.release() to the end of the second thread&lt;/li&gt;
&lt;li&gt;Add semaphore2.acquire() to the beginning of the third thread&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check out the full java code here: Print in Order - LeetCode &lt;a href="https://leetcode.com/problems/print-in-order/submissions/"&gt;https://leetcode.com/problems/print-in-order/submissions/&lt;/a&gt; &lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>DAY 3: Palindrom number</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Fri, 23 Sep 2022 07:42:15 +0000</pubDate>
      <link>https://dev.to/eazylink/day-3-palindrom-number-4go</link>
      <guid>https://dev.to/eazylink/day-3-palindrom-number-4go</guid>
      <description>&lt;p&gt;Hey! It's day 3 of I4G 10 days coding challenge. Today's task was to write a code that checks if an integer is a palindrome number. A palindrome number is number that gives the same result when reversed.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Strategy: *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition of problem:&lt;/strong&gt; I need to understand what the problem is before diving into the solution. To achieve I made research on google of what a palindrome number is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Algorithm:&lt;/strong&gt; Having understood the problem I wrote an algorithm to help me narrow down the problem into solution. The Algorithm is as shown below:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declare three integer variables: remainder, original and reverse&lt;/li&gt;
&lt;li&gt;Initialize reverse to 0 and set original to the given integer&lt;/li&gt;
&lt;li&gt;Set a while loop with condition: x(given integer) != 0&lt;/li&gt;
&lt;li&gt;while the condition is true set remainder = x % 10, reverse = reverse * 10 + remainder and x = x / 10&lt;/li&gt;
&lt;li&gt;Return true if reverse is same original else return false&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the complete code here:  Palindrome Number - LeetCode &lt;a href="https://leetcode.com/problems/palindrome-number/submissions/"&gt;https://leetcode.com/problems/palindrome-number/submissions/&lt;/a&gt; &lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
    </item>
    <item>
      <title>Day 2 of 10days coding challenge: Remove element</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Thu, 22 Sep 2022 22:15:40 +0000</pubDate>
      <link>https://dev.to/eazylink/day-2-of-10days-coding-challenge-remove-element-ef2</link>
      <guid>https://dev.to/eazylink/day-2-of-10days-coding-challenge-remove-element-ef2</guid>
      <description>&lt;p&gt;Hey! I just completed my day 2 challenge for 10days coding challenge with Ingressive4good. Today's task was to write a code that removes a given element from an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's my approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I need two arrays to achieve this, the first one is the given array while the second one is the new array without the elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I need two integers, the first to iterate through the given array while the second to generate the length of the new array&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I need to check through the given array and return new array with the given value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Initialize integer i to zero and declare integer k&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use for loop to iterate through nums array with condition: k &amp;lt; nums.length&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;check if each value of the array is not equal to the given element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If not equal set nums[i] = nums[k] and increment i&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return the value of i.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check out the code here  Remove Element - LeetCode &lt;a href="https://leetcode.com/problems/remove-element/submissions/"&gt;https://leetcode.com/problems/remove-element/submissions/&lt;/a&gt; &lt;/p&gt;

</description>
      <category>java</category>
      <category>codereview</category>
    </item>
    <item>
      <title>Code to remove duplicates</title>
      <dc:creator>Ezekiel nwuguru</dc:creator>
      <pubDate>Wed, 21 Sep 2022 22:22:31 +0000</pubDate>
      <link>https://dev.to/eazylink/code-to-remove-duplicates-1o05</link>
      <guid>https://dev.to/eazylink/code-to-remove-duplicates-1o05</guid>
      <description>&lt;p&gt;Thought process:&lt;br&gt;
In other to achieve this, I need an empty array to store the unique value while iterating through the sorted array. To achieve this uniqueness, I compared the previous element to the next one and made sure they are not the same before storing it in the unique array.&lt;/p&gt;

&lt;p&gt;Below is the screen shot of the whole approach.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
