<?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: Abubakar Sadiq Ismail</title>
    <description>The latest articles on DEV Community by Abubakar Sadiq Ismail (@abubakarismail).</description>
    <link>https://dev.to/abubakarismail</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%2F464386%2F15888183-ec3e-4e26-b33b-762d80e170cb.jpg</url>
      <title>DEV Community: Abubakar Sadiq Ismail</title>
      <link>https://dev.to/abubakarismail</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abubakarismail"/>
    <language>en</language>
    <item>
      <title>3Sum Closest</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Sun, 09 Oct 2022 16:07:52 +0000</pubDate>
      <link>https://dev.to/abubakarismail/3sum-closest-2jpi</link>
      <guid>https://dev.to/abubakarismail/3sum-closest-2jpi</guid>
      <description>&lt;p&gt;Problem 3 Closest Sum&lt;br&gt;
Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.&lt;/p&gt;

&lt;p&gt;Return the sum of the three integers.&lt;/p&gt;

&lt;p&gt;You may assume that each input would have exactly one solution.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;/p&gt;

&lt;p&gt;Input: nums = [-1,2,1,-4], target = 1&lt;br&gt;
Output: 2&lt;br&gt;
Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: nums = [0,0,0], target = 1&lt;br&gt;
Output: 0&lt;br&gt;
Explanation: The sum that is closest to the target is 0. (0 + 0 + 0 = 0).&lt;/p&gt;

&lt;p&gt;The idea that a lot of people will think of is to brute force all the possible 3 combinations of integers in the nums array sum them and return the closest one.&lt;br&gt;
This solution works but comes with a cost which is the high time complexity of O(n^3)&lt;/p&gt;

&lt;p&gt;There is a better way to do it, yes there is.&lt;br&gt;
Using the two pointer technique.&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/two-pointers-technique/"&gt;&lt;em&gt;Read about two pointer technique&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First Sort the array of nums.&lt;br&gt;
the time complexity of the sorting nums is nlog(n)&lt;/p&gt;

&lt;p&gt;declare the maxSum = 0&lt;/p&gt;

&lt;p&gt;Then loop through the array from 0 to n-2.&lt;/p&gt;

&lt;p&gt;Declare the two pointers&lt;br&gt;
l = i + 1&lt;br&gt;
r = n -1&lt;br&gt;
loop while l &amp;lt; r&lt;br&gt;
calculate the sum as nums[i] + nums[l] + nums[r]&lt;/p&gt;

&lt;p&gt;check if i = 0 sum &amp;gt; 0;&lt;br&gt;
reassign maxSum = sum&lt;/p&gt;

&lt;p&gt;check if sum == target&lt;br&gt;
if yes return sum&lt;/p&gt;

&lt;p&gt;check if sum is closer than previous sum;&lt;br&gt;
if sum &amp;gt; 0&lt;br&gt;
check if target-sum &amp;lt; target-maxSum&lt;br&gt;
if yes maxSum = sum&lt;br&gt;
else sum &amp;lt; 0&lt;br&gt;
target-sum &amp;gt; target -maxSum&lt;br&gt;
maxSum = sum&lt;/p&gt;

&lt;p&gt;Next is to move the pointer&lt;/p&gt;

&lt;p&gt;if sum &amp;lt; target&lt;br&gt;
increment l pointer&lt;/p&gt;

&lt;p&gt;if sum &amp;gt; target&lt;br&gt;
decrement r counter&lt;/p&gt;

&lt;p&gt;and hence you don't have to bother about missing the values because the array is sorted.&lt;br&gt;
nums[r] pointer is the max value hence you decrease r pointer to reduce the sum, and check again.&lt;/p&gt;

&lt;p&gt;else if sum is less than target nums[l] pointer is the smallest and hence you increment the counter value, l=l+1, nums[l+1] which is larger than nums[l] hence you decrease in other to check for l+1.&lt;br&gt;
until l == r.&lt;br&gt;
Then you increment break out inner loop and continue to the first loop by incrementing i.&lt;br&gt;
set l to i+1&lt;br&gt;
set r to n-1.&lt;br&gt;
Repeat the process&lt;br&gt;
And when you get to i = n-2. Repeat the process stop and&lt;br&gt;
Return MaxSum. &lt;br&gt;
Given the time complexity as nlog(n) + O(n^2).&lt;br&gt;
We take the max And the overall time complexity is O(n^2)&lt;br&gt;
with O(1) space complexity.&lt;/p&gt;

</description>
      <category>twopointer</category>
      <category>algorithms</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Find the element that appear once in array</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Tue, 04 Oct 2022 15:00:52 +0000</pubDate>
      <link>https://dev.to/abubakarismail/find-the-element-that-appear-once-in-array-1955</link>
      <guid>https://dev.to/abubakarismail/find-the-element-that-appear-once-in-array-1955</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Given an array with items.&lt;br&gt;
each item in the array appear twice except once element.&lt;br&gt;
E.g [1,4,3,4,1]&lt;br&gt;
here the element 3 appear only once hence it should be returned.&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Prerequisite knowledge hashMap or Dictionary.&lt;/em&gt;&lt;br&gt;
How do you find the element.&lt;br&gt;
Using Dictionary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 Create a Dictionary&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;2 Assign the key of the dictionary as the array items, and the value as count of times it appears in the array&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;3 Return the dictionary item with the value of 1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Create items dictionary&lt;br&gt;
Loop through the array i = 0,....n = length of the array-1.&lt;br&gt;
If the array[i] is not a key in the items dictionary create a key with value of 1&lt;br&gt;
if the array[i] is a key in the dictionary increment the value by 1.&lt;/p&gt;

&lt;p&gt;Loop through the dictionary of items to get the key with 1 as value and return it, if all are more than one.&lt;/p&gt;

&lt;p&gt;return -1. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Time Complexity O(n)&lt;/em&gt;&lt;br&gt;
Because we are looping through the array n times.&lt;br&gt;
&lt;em&gt;Space Complexity O(n)&lt;/em&gt;&lt;br&gt;
Because we are creating a map with at worst case n keys.&lt;/p&gt;

</description>
      <category>array</category>
      <category>python</category>
    </item>
    <item>
      <title>Linear Search</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Mon, 03 Oct 2022 22:05:40 +0000</pubDate>
      <link>https://dev.to/abubakarismail/linear-search-4fio</link>
      <guid>https://dev.to/abubakarismail/linear-search-4fio</guid>
      <description>&lt;p&gt;Linear search algorithm.&lt;/p&gt;

&lt;p&gt;Given an array of items.&lt;br&gt;
You want to find the given index of an element.&lt;br&gt;
The linear search algorithm returns the index of the element, or -1 if the element is not found.&lt;/p&gt;

&lt;p&gt;Linear search works by going through the array from index 0,....n-1 &lt;br&gt;
comparing array[index] to element.&lt;br&gt;
If they match you return the index.&lt;/p&gt;

&lt;p&gt;if the array elements are compared from index 0 to n-1 and no element matches the element.&lt;br&gt;
you return -1.&lt;/p&gt;

&lt;p&gt;Hence the pseudo code&lt;br&gt;
Loop through  array from index =  0, to n-1.&lt;br&gt;
if array[index] = element&lt;br&gt;
return index &lt;/p&gt;

&lt;p&gt;return - 1&lt;/p&gt;

&lt;p&gt;Time Complexity is O(n).&lt;br&gt;
because we are looping through the array n times.&lt;br&gt;
Space Complexity is O(1).&lt;br&gt;
We are not creating any new variable and hence using constant space complexity&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>python</category>
    </item>
    <item>
      <title>Day 10 I4G10DaysofCodeChallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Fri, 30 Sep 2022 20:05:29 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-10-i4g10daysocodechallenge-4ed7</link>
      <guid>https://dev.to/abubakarismail/day-10-i4g10daysocodechallenge-4ed7</guid>
      <description>&lt;p&gt;Day 10.&lt;br&gt;
Final day,&lt;br&gt;
A valid number can be split up into these components (in order):&lt;/p&gt;

&lt;p&gt;A decimal number or an integer.&lt;br&gt;
(Optional) An 'e' or 'E', followed by an integer.&lt;br&gt;
A decimal number can be split up into these components (in order):&lt;/p&gt;

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

&lt;p&gt;(Optional) A sign character (either '+' or '-').&lt;br&gt;
One or more digits.&lt;br&gt;
For example, all the following are valid numbers: ["2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789"], while the following are not valid numbers: ["abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53"].&lt;/p&gt;

&lt;p&gt;Given a string s, return true if s is a valid number&lt;/p&gt;

&lt;p&gt;This problem was indeed hard you can tell by the number of dislike, the requirements are many and there are a lot of edge Cases I spent hours figuring how to solve it.&lt;/p&gt;

&lt;p&gt;I first check for edge cases like when string is Empty, or has 1 non-Integer character and return false. &lt;br&gt;
I decide to check whether the string is a valid integer, or a decimal number, &lt;br&gt;
By writing two methods, &lt;br&gt;
checkInteger, and checkDecimal, &lt;br&gt;
CheckInteger convert the string to a number and if it's true return true.&lt;br&gt;
check decimal checks the string and verify if its a decimal number, by verifying no characters, other than (+,-,e,E,.) and they don't appear twice.&lt;br&gt;
No '.' after e.&lt;br&gt;
This method works for 1438 test-cases but failed because the string can contain one of the (+,-,e,E,.)  but  still the are arrange in a way that makes the string invalid number e.g "4e+".&lt;/p&gt;

&lt;p&gt;The solution is to split the input by the e or E and follow the validation rule that is check if it's integer or decimal.&lt;br&gt;
"4e", "+" and apply  the validation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/valid-number/description/"&gt;Leetcode problem&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/validNumber.py"&gt;Implementation in python&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 9 I4G 10daysofcodechallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Thu, 29 Sep 2022 22:51:11 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-9-i4g-10daysofcodechallenge-1di6</link>
      <guid>https://dev.to/abubakarismail/day-9-i4g-10daysofcodechallenge-1di6</guid>
      <description>&lt;p&gt;You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.&lt;/p&gt;

&lt;p&gt;Merge all the linked-lists into one sorted linked-list and return it.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;/p&gt;

&lt;p&gt;Input: lists = [[1,4,5],[1,3,4],[2,6]]&lt;br&gt;
Output: [1,1,2,3,4,4,5,6]&lt;br&gt;
Explanation: The linked-lists are:&lt;br&gt;
[&lt;br&gt;
  1-&amp;gt;4-&amp;gt;5,&lt;br&gt;
  1-&amp;gt;3-&amp;gt;4,&lt;br&gt;
  2-&amp;gt;6&lt;br&gt;
]&lt;br&gt;
merging them into one sorted list:&lt;br&gt;
1-&amp;gt;1-&amp;gt;2-&amp;gt;3-&amp;gt;4-&amp;gt;4-&amp;gt;5-&amp;gt;6&lt;/p&gt;

&lt;p&gt;Problem Category Hard!!!, Omo&lt;/p&gt;

&lt;p&gt;The first idea I got was to merge the lists to a single list and the sort the whole merged lists, using a sorting algorithm, like merge sort.&lt;br&gt;
Think I think of complexity and how to simplify it.&lt;br&gt;
Which is why should I merge the list all.&lt;br&gt;
I then get the first list,&lt;br&gt;
combine the first with second link sorted,&lt;br&gt;
continuously until I reach the end of the list.&lt;/p&gt;

&lt;p&gt;Complexity is O(n+k)&lt;br&gt;
Space Complexity O(k) &lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/merge-k-sorted-lists/"&gt;Problem inn leetcode&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/mergeList.js"&gt;Solution Implementation in js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Day 8 I4G10daysofCodeChallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Wed, 28 Sep 2022 20:57:07 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-8-i4g10daysofcodechallenge-26db</link>
      <guid>https://dev.to/abubakarismail/day-8-i4g10daysofcodechallenge-26db</guid>
      <description>&lt;p&gt;Problem: Given a two SQL tables A,B in a database Combine them. with a common column in A and B and rows that doesn't have a common fields should return null in the B fields.&lt;/p&gt;

&lt;p&gt;Table: Person&lt;/p&gt;

&lt;p&gt;+-------------+---------+&lt;br&gt;
| Column Name | Type    |&lt;br&gt;
+-------------+---------+&lt;br&gt;
| personId    | int     |&lt;br&gt;
| lastName    | varchar |&lt;br&gt;
| firstName   | varchar |&lt;br&gt;
+-------------+---------+&lt;br&gt;
personId is the primary key column for this table.&lt;br&gt;
This table contains information about the ID of some persons and their first and last names.&lt;/p&gt;

&lt;p&gt;Table: Address&lt;/p&gt;

&lt;p&gt;+-------------+---------+&lt;br&gt;
| Column Name | Type    |&lt;br&gt;
+-------------+---------+&lt;br&gt;
| addressId   | int     |&lt;br&gt;
| personId    | int     |&lt;br&gt;
| city        | varchar |&lt;br&gt;
| state       | varchar |&lt;br&gt;
+-------------+---------+&lt;br&gt;
addressId is the primary key column for this table.&lt;br&gt;
Each row of this table contains information about the city and state of one person with ID = PersonId.&lt;/p&gt;

&lt;p&gt;Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.&lt;/p&gt;

&lt;p&gt;Example :&lt;/p&gt;

&lt;p&gt;Input: &lt;br&gt;
Person table:&lt;br&gt;
+----------+----------+-----------+&lt;br&gt;
| personId | lastName | firstName |&lt;br&gt;
+----------+----------+-----------+&lt;br&gt;
| 1        | Wang     | Allen     |&lt;br&gt;
| 2        | Alice    | Bob       |&lt;br&gt;
+----------+----------+-----------+&lt;br&gt;
Address table:&lt;br&gt;
+-----------+----------+---------------+------------+&lt;br&gt;
| addressId | personId | city          | state      |&lt;br&gt;
+-----------+----------+---------------+------------+&lt;br&gt;
| 1         | 2        | New York City | New York   |&lt;br&gt;
| 2         | 3        | Leetcode      | California |&lt;br&gt;
+-----------+----------+---------------+------------+&lt;br&gt;
Output: &lt;br&gt;
+-----------+----------+---------------+----------+&lt;br&gt;
| firstName | lastName | city          | state    |&lt;br&gt;
+-----------+----------+---------------+----------+&lt;br&gt;
| Allen     | Wang     | Null          | Null     |&lt;br&gt;
| Bob       | Alice    | New York City | New York |&lt;br&gt;
+-----------+----------+---------------+----------+&lt;/p&gt;

&lt;p&gt;Solution.&lt;/p&gt;

&lt;p&gt;After reading through the solution I understand that what I need to do is to join Table A and B, using the LEFT JOIN.&lt;br&gt;
Such that values that if some Rows in column A don't have the personId in them they should return null in the fields.&lt;/p&gt;

&lt;p&gt;SELECT P.lastName, P.firstName, A.city, A.state&lt;br&gt;
FROM Person P LEFT JOIN Address A ON P.personId = A.personId&lt;br&gt;
I read about sql Joins&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/sql-query-to-combine-two-tables-without-a-common-column/"&gt;GeeksforGeeks SQL Join&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.educba.com/sql-join-two-tables/"&gt;Joining two tables&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/combine-two-tables/"&gt;Leetcode problem&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 7 I4G 10DaysofCodeChallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Tue, 27 Sep 2022 22:51:59 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-7-i4g-10daysofcodechallenge-39ko</link>
      <guid>https://dev.to/abubakarismail/day-7-i4g-10daysofcodechallenge-39ko</guid>
      <description>&lt;p&gt;Problem: UTF-8 Validation&lt;br&gt;
Category: Medium&lt;br&gt;
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters).&lt;/p&gt;

&lt;p&gt;A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:&lt;/p&gt;

&lt;p&gt;For a 1-byte character, the first bit is a 0, followed by its Unicode code.&lt;br&gt;
For an n-bytes character, the first n bits are all one's, the n + 1 bit is 0, followed by n - 1 bytes with the most significant 2 bits being 10.&lt;/p&gt;

&lt;p&gt;For UTF-8 we are going to check 4 bytes long that n=1,2,3,4..&lt;br&gt;
    1          |   0xxxxxxx&lt;br&gt;
            2          |   110xxxxx 10xxxxxx&lt;br&gt;
            3          |   1110xxxx 10xxxxxx 10xxxxxx&lt;br&gt;
            4          |   11110xxx 10xxxxxx 10xxxxxx &lt;br&gt;
10xxxxxx&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;Input: data = [197,130,1]&lt;br&gt;
Output: true&lt;br&gt;
Explanation: data represents the octet sequence: 11000101 10000010 00000001.&lt;br&gt;
It is a valid utf-8 encoding for a 2-bytes character followed by a 1-byte character.&lt;br&gt;
Solution&lt;br&gt;
For Each interger in the input array&lt;br&gt;
1.Convert to 8 bits binary representation.&lt;br&gt;
For the integer 197 = 11000101 &lt;/p&gt;

&lt;p&gt;Check for n = 1,2,3 conditions.&lt;br&gt;
and return the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/utf-8-validation/"&gt;Problem&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/utf8.py"&gt;Solution Implementation&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 6 I4G 10DaysOfCodeChallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Mon, 26 Sep 2022 22:38:49 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-6-i4g-10daysofcodechallenge-1p7e</link>
      <guid>https://dev.to/abubakarismail/day-6-i4g-10daysofcodechallenge-1p7e</guid>
      <description>&lt;p&gt;Problem 6: Fizz Buzz Multithreaded.&lt;br&gt;
Category Medium.&lt;br&gt;
Given a class FizzBuzz, with 4 methods fizz (which print fizz),buzz (which print buzz),fizzBuzz (which print fizzBuzz), and printNumber( print a number).&lt;br&gt;
FizzBuzz will be initialized with an integer n.&lt;br&gt;
All four methods will be called from different threads.&lt;br&gt;
the result of running all four threads.&lt;br&gt;
Should be based on i which is 1 to n;&lt;/p&gt;

&lt;p&gt;if i % 3 and i % 5 is 0;&lt;br&gt;
return fizzBuzz&lt;br&gt;
if i % 3 is 0;&lt;br&gt;
return fizz&lt;br&gt;
if i % 5 is 0;&lt;br&gt;
return buzz&lt;br&gt;
else if i % 3 and i % 5 is not 0;&lt;br&gt;
return i&lt;br&gt;
.&lt;br&gt;
This problem as well Javascript is not in the programming language because it's single threaded.&lt;br&gt;
Hence I use python to create another threads when all the threads are started.&lt;br&gt;
When the last thread is started.&lt;br&gt;
Iterate through n.&lt;br&gt;
check the condition and call the appropriate  thread or printNumber with i&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/fizz-buzz-multithreaded"&gt;Problem&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/fizzBuzz.py"&gt;Solution Implementation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>python</category>
    </item>
    <item>
      <title>Day 5 I4G 10 Days Code Challenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Sun, 25 Sep 2022 21:23:31 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-5-i4g-10-days-code-challenge-2c62</link>
      <guid>https://dev.to/abubakarismail/day-5-i4g-10-days-code-challenge-2c62</guid>
      <description>&lt;p&gt;We are half way Day 5;&lt;br&gt;
Problem: The problem is given a string you should sort it base on the character that has the highest frequency;&lt;br&gt;
E.g given 'aabbbcdee'&lt;br&gt;
'bbb' has highest frequency ,followed by 'aa' and 'ee' (has same frequency), then 'c' and 'd' (has same frequency).&lt;br&gt;
hence the output should be 'bbbaaeecd'&lt;br&gt;
Note for characters that have same frequency they can be in any order; that is the output can as well be 'bbbeeaadc';&lt;br&gt;
Category: &lt;strong&gt;Medium&lt;/strong&gt; we are getting their right!!!&lt;/p&gt;

&lt;p&gt;Solution that came to my mind is to use hash map.&lt;/p&gt;

&lt;p&gt;Step One&lt;br&gt;
The Map keys are characters and the values are the characters frequency;&lt;br&gt;
E.g of the map for the above Testcase will be;&lt;br&gt;
{'b':3,'a':2,'e':2,'c':1,'d':1}&lt;/p&gt;

&lt;p&gt;You can Get this by iterating through the string and creating the property or if it exist incrementing its value.&lt;/p&gt;

&lt;p&gt;Step Two&lt;br&gt;
Then create an array of arrays with two values character and the number of time it occurs;&lt;br&gt;
e.g [['b',3],['a',2],['e',2],['c',1],['d',1]]&lt;br&gt;
using Javascript in-built Object.entries(Object) method&lt;/p&gt;

&lt;p&gt;Iterate through the array the create another Hash map with the keys as number of time character occurs and the value as array of the characters.&lt;br&gt;
E.g&lt;br&gt;
{'1':['c','d'],'2':['e','a'],3:['b']}&lt;/p&gt;

&lt;p&gt;Get all the keys of the map using Object.keys(Object) method;&lt;br&gt;
E.g ['1','2','3'];&lt;br&gt;
Create the returned string&lt;br&gt;
iterate through the keys starting from the highest, get all the characters and multiply it by the time it occur, increment it into the string.&lt;br&gt;
Until the last key.&lt;br&gt;
Return the string&lt;/p&gt;

&lt;p&gt;Pretty Long right.&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n)&lt;br&gt;
Space Complexity: O(n)&lt;br&gt;
&lt;a href="https://leetcode.com/problems/sort-characters-by-frequency/"&gt;Sort Characters by frequency&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/sortStringWithFrequency.js"&gt;Solution Implementation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>programming</category>
    </item>
    <item>
      <title>Day 4 I4G Code Challenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Sat, 24 Sep 2022 22:30:34 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-4-i4g-code-challenge-1cc4</link>
      <guid>https://dev.to/abubakarismail/day-4-i4g-code-challenge-1cc4</guid>
      <description>&lt;p&gt;Day 4!!!! Yay&lt;br&gt;
Today's problem is interesting and challenging as well Javascript is not included in the programming language I can solve the problem with. &lt;br&gt;
So I had to choose another programming language, python is always the next tool to use if Js will not solve my problem&lt;br&gt;
.&lt;br&gt;
The problem statement seems bizarre and a big problem but it's pretty simple and straight forward when you understand the problem.&lt;br&gt;
Problem. Print In order&lt;br&gt;
Tag: Easy&lt;br&gt;
Given three method in a class&lt;br&gt;
class foo():&lt;/p&gt;

&lt;p&gt;firt(self):&lt;br&gt;
     print("first line")&lt;/p&gt;

&lt;p&gt;second(self):&lt;br&gt;
     print("second line")&lt;br&gt;
   third(self):&lt;br&gt;
     print("third line")&lt;/p&gt;

&lt;p&gt;The task is to modify the above methods such that calling&lt;br&gt;
foo = foo()&lt;/p&gt;

&lt;p&gt;foo.first()&lt;br&gt;
foo.second()&lt;br&gt;
foo.third()&lt;br&gt;
//or&lt;br&gt;
foo.first()&lt;br&gt;
foo.third()&lt;br&gt;
foo.second()&lt;/p&gt;

&lt;p&gt;//or&lt;br&gt;
foo.third()&lt;br&gt;
foo.first()&lt;br&gt;
foo.second()&lt;/p&gt;

&lt;p&gt;Or any permutation of this calls can result in&lt;br&gt;
//first line&lt;br&gt;
//second line&lt;br&gt;
// third line&lt;br&gt;
irrespective of how they are called;&lt;/p&gt;

&lt;p&gt;What first come to my mind is to delay third method for some time,delay second method for less time and first method will fire immediately.&lt;br&gt;
So that third will wait for first and second, second will wait for first. &lt;br&gt;
first fires immediately.&lt;br&gt;
I use python in built time module for that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/print-in-order/"&gt;Print Order problem&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/printOrder.py"&gt;Code Implementation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
    </item>
    <item>
      <title>Day 3 I4G 10 days of code challenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Fri, 23 Sep 2022 21:15:46 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-3-i4g-10-days-of-code-challenge-11n</link>
      <guid>https://dev.to/abubakarismail/day-3-i4g-10-days-of-code-challenge-11n</guid>
      <description>&lt;p&gt;Early in the morning after I wake up, I decided to start with todays code challenge before anything else;&lt;/p&gt;

&lt;p&gt;The problem was given an integer you return true when it's a palindrome, else return false.&lt;br&gt;
Palindrome are numbers,phrase or strings that when reversed the result is the same number;&lt;br&gt;
e.g 1221 is a palindrome and will return true. 1234 is not a palindrome and will return false.&lt;/p&gt;

&lt;p&gt;The solution i think is to covert the integer to a string;&lt;br&gt;
Reverse the string; &lt;br&gt;
Convert the reversed string to an integer;&lt;br&gt;
Compare the original integer and the reversed Integer,&lt;br&gt;
If they are the same return true&lt;br&gt;
Else return false&lt;/p&gt;

&lt;p&gt;Time complexity &lt;br&gt;
O(n)&lt;br&gt;
Space complexity&lt;br&gt;
O(n)&lt;br&gt;
&lt;a href="https://leetcode.com/problems/palindrome-number/"&gt;Leetcode problem&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/palindromeNumber.js"&gt;Link to Implementation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Day 2 I4G #10Dayscodechallenge</title>
      <dc:creator>Abubakar Sadiq Ismail</dc:creator>
      <pubDate>Thu, 22 Sep 2022 22:34:31 +0000</pubDate>
      <link>https://dev.to/abubakarismail/day-2-i4g-10dayscodechallenge-5b97</link>
      <guid>https://dev.to/abubakarismail/day-2-i4g-10dayscodechallenge-5b97</guid>
      <description>&lt;p&gt;Todays challenge was removing an Element from an array, with O(1) space complexity.&lt;br&gt;
E.g given arr=  [1,2,3,4,3,3,3] remove all 3 in arr&lt;br&gt;
return the number of array without the element which is  3.&lt;br&gt;
Question Tag: Easy&lt;/p&gt;

&lt;p&gt;The first thing that came to my mind is to use pointer from index 0;&lt;br&gt;
pointer = 0;&lt;br&gt;
Iterate through the array;&lt;br&gt;
If current iteration value is not the same as the element &lt;br&gt;
update pointer with it;&lt;br&gt;
Increment pointer&lt;/p&gt;

&lt;p&gt;return the value of pointer;&lt;br&gt;
with O(n) time complexity and O(1) space complexity;&lt;/p&gt;

&lt;p&gt;Pseudocode&lt;br&gt;
array = [...], val = x;&lt;br&gt;
Pointer = 0&lt;br&gt;
for item in array&lt;br&gt;
 if item != val&lt;br&gt;
    array[pointer] = item&lt;br&gt;
    pointer++&lt;/p&gt;

&lt;p&gt;return pointer&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/removeElement.js"&gt;Code Implementation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/remove-element/"&gt;Leet code problem&lt;/a&gt;&lt;/p&gt;

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