<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Travis Lee on Medium]]></title>
        <description><![CDATA[Stories by Travis Lee on Medium]]></description>
        <link>https://medium.com/@travisslee223?source=rss-98480780c320------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*anSrgRzyudGlJjHWJgwNaw.jpeg</url>
            <title>Stories by Travis Lee on Medium</title>
            <link>https://medium.com/@travisslee223?source=rss-98480780c320------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:45:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@travisslee223/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Birthday Cake Candles Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/birthday-cake-candles-solution-in-javascript-84477497b10f?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/84477497b10f</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 31 Dec 2021 02:51:27 GMT</pubDate>
            <atom:updated>2021-12-31T02:51:27.480Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p><strong>Problem</strong></p><p>You are in charge of the cake for a child’s birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest.</p><p><strong>Example</strong></p><p>candles = [4,4,1,3]</p><p>The maximum height candles are 4 units high. There are 2 of them, so return 2.</p><p><strong>Function Description</strong></p><p>Complete the function birthdayCakeCandles in the editor below.</p><p>birthdayCakeCandles has the following parameter(s):</p><ul><li>int candles[n]: the candle heights</li></ul><p><strong>Returns</strong></p><ul><li>int: the number of candles that are tallest</li></ul><p><strong>Input Format</strong></p><p>The first line contains a single integer, n, the size of candles[].<br>The second line contains n space-separated integers, where each integer i describes the height of candles[i].</p><p><strong>Constraints</strong></p><ul><li>1 ≤ n ≤ 10⁵</li><li>1 ≤ candles[i] ≤ 10⁷</li></ul><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*bm-Uw5Lha17liDIbWEpj-Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84477497b10f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Very Big Sum Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/a-very-big-sum-solution-in-javascript-f88f60bdb8c5?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/f88f60bdb8c5</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 01:16:57 GMT</pubDate>
            <atom:updated>2021-12-24T01:18:44.043Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p><strong>Problem</strong></p><p>In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.</p><p><strong>Function Description</strong></p><p>Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements.</p><p>aVeryBigSum has the following parameter(s):</p><ul><li>int ar[n]: an array of integers .</li></ul><p><strong>Return</strong></p><ul><li>long: the sum of all array elements</li></ul><p><strong>Input Format</strong></p><p>The first line of the input consists of an integer n.<br>The next line contains n space-separated integers contained in the array.</p><p><strong>Output Format</strong></p><p>Return the integer sum of the elements in the array.</p><p><strong>Constraints</strong></p><ul><li>1 ≤ n ≤ 10</li><li>0 ≤ ar[i] ≤ 10¹⁰</li></ul><p><strong>Sample Input</strong></p><pre>5<br>1000000001 1000000002 1000000003 1000000004 1000000005</pre><p><strong>Output</strong></p><pre>5000000015</pre><p><strong>Note:</strong></p><p>The range of the 32-bit integer is</p><p>(-2³¹) to (2³¹ — 1) or [-2147483648, 2147483648].</p><p>When we add several integer values, the resulting sum might exceed the above range. You might need to use long int C/C++/Java to store such sums.</p><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dq8Bm5nCl5LIfl94Me4zIw.png" /></figure><p>First, we create a const called reducer which will serve as a function in reducing the array. Then, we set the sum equal to the arr with the reduce function along with the reducer callback. Finally, we return the sum.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f88f60bdb8c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Array Sum Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/simple-array-sum-solution-in-javascript-d832358995b2?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/d832358995b2</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 17 Dec 2021 01:56:04 GMT</pubDate>
            <atom:updated>2021-12-17T01:56:04.000Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p><strong>Problem</strong></p><p>Given an array of integers, find the sum of its elements.</p><p>For example, if the array ar = [1,2,3], 1 + 2 + 3 = 6, so return 6.</p><p><strong>Function Description</strong></p><p>Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer.</p><p>simpleArraySum has the following parameter(s):</p><ul><li>ar: an array of integers</li></ul><p><strong>Input Format</strong></p><p>The first line contains an integer, n, denoting the size of the array.<br>The second line contains nspace-separated integers representing the array’s elements.</p><p><strong>Constraints</strong></p><p>0 &lt; n, ar[i] ≤ 100</p><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvglJwFWjsaTDTYrQaeRtw.png" /></figure><p>First, we create a const called reducer which will serve as a function in reducing the array. Then, we set the sum equal to the arr with the reduce function along with the reducer callback. Finally, we return the sum.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d832358995b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Divisible Sum Pairs Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/divisible-sum-pairs-solution-in-javascript-2b2b6d4c491e?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b2b6d4c491e</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 10 Dec 2021 00:04:02 GMT</pubDate>
            <atom:updated>2021-12-10T00:04:02.542Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p>Given an array of integers and a positive integer k, determine the number of (i,j)pairs where i &lt; j and ar[i]+ ar[j] is divisible by k.</p><p><strong>Example</strong></p><p>ar = [1,2,3,4,5,6]</p><p>k=5</p><p>Three pairs meet the criteria: [1,4],[2,3] and [4,6] .</p><p><strong>Function Description</strong></p><p>Complete the divisibleSumPairs function in the editor below.</p><p>divisibleSumPairs has the following parameter(s):</p><ul><li>int n: the length of array ar</li><li>int ar[n]: an array of integers</li><li>int k: the integer divisor</li></ul><p><strong>Returns</strong><br>- int: the number of pairs</p><p><strong>Input Format</strong></p><p>The first line contains 2 space-separated integers, n and k.<br>The second line contains n space-separated integers, each a value of arr[i].</p><p><strong>Constraints</strong></p><ul><li>2 ≤ n ≤ 100</li><li>1 ≤ k ≤ 100</li><li>1 ≤ ar[i] ≤ 100</li></ul><p>Solution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*fUVVoj44JWcDaZqU3bE0fA.png" /></figure><p>To find results that equal to k in the most brute way possible, we set 2 for loops in order to compare numbers in the array. If the sum divided by k has no remainder, we add one to the counter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b2b6d4c491e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hurdle Race in Javascript]]></title>
            <link>https://travisslee223.medium.com/the-hurdle-race-in-javascript-674db4d2bb9c?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/674db4d2bb9c</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 17:22:19 GMT</pubDate>
            <atom:updated>2021-12-03T17:22:19.969Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p><strong>Problem</strong></p><p>A video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by 1 unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return .</p><p><strong>Example</strong></p><p>height = [1,2,3,3,2]</p><p>k = 1</p><p>The character can jump 1 unit high initially and must take 3–1= 2 doses of potion to be able to jump all of the hurdles.</p><p><strong>Function Description</strong></p><p>Complete the hurdleRace function in the editor below.</p><p>hurdleRace has the following parameter(s):</p><ul><li>int k: the height the character can jump naturally</li><li>int height[n]: the heights of each hurdle</li></ul><p><strong>Returns</strong></p><ul><li>int: the minimum number of doses required, always 0 or more</li></ul><p><strong>Input Format</strong></p><p>The first line contains two space-separated integers n and k, the number of hurdles and the maximum height the character can jump naturally.<br>The second line contains n space-separated integers height[i] where 0 ≤ i &lt; n.</p><p><strong>Constraints</strong></p><ul><li>1 ≤ n,k ≤ 100</li><li>1 ≤ height[i] ≤ 100</li></ul><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*6M0bL_GKw35j_T9XrSSMsQ.png" /></figure><p>First, we set the variable maxHeight to biggest number in the array and result to 0. The Math.max() function will find the biggest number in the data pool you give it. Then, if the max height the player could jump is greater than the maxHeight, we return the result is 0 because they do not need to drink the potions. On the other hand, we return the result as maxHeight — k to represent the number of potions the player needs to drink in order to the jump the hurdle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=674db4d2bb9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Library Fine Solution In Javascript]]></title>
            <link>https://travisslee223.medium.com/library-fine-solution-in-javascript-7bf2aba1141e?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bf2aba1141e</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Thu, 25 Nov 2021 20:57:20 GMT</pubDate>
            <atom:updated>2021-11-25T20:57:20.818Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p><strong>Problem</strong></p><p>Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows:</p><ol><li>If the book is returned on or before the expected return date, no fine will be charged (i.e.: fine = 0) .</li><li>If the book is returned after the expected return day but still within the same calendar month and year as the expected return date, fine = 15 Hackos x (the number of days late).</li><li>If the book is returned after the expected return month but still within the same calendar year as the expected return date, the fine = 500 Hackos x (the number of months late).</li><li>If the book is returned after the calendar year in which it was expected, there is a fixed fine of 10,000 Hackos.</li></ol><p>Charges are based only on the least precise measure of lateness. For example, whether a book is due January 1, 2017 or December 31, 2017, if it is returned January 1, 2018, that is a year late and the fine would be .</p><p><strong>Example</strong></p><p>d1, m1, y1 = 14,7,2018</p><p>d2, m2, y2 = 5,7,2018</p><p>The first values are the return date and the second are the due date. The years are the same and the months are the same. The book is 14 -5 = 9days late. Return 9 * 15 = 135.</p><p><strong>Function Description</strong></p><p>Complete the libraryFine function in the editor below.</p><p>libraryFine has the following parameter(s):</p><ul><li>d1, m1, y1: returned date day, month and year, each an integer</li><li>d2, m2, y2: due date day, month and year, each an integer</li></ul><p><strong>Returns</strong></p><ul><li>int: the amount of the fine or 0 if there is none</li></ul><p><strong>Input Format</strong></p><p>The first line contains 3 space-separated integers, d1,m1,y1, denoting the respective day, month, and year on which the book was returned.<br>The second line contains 3 space-separated integers, d2,m2,y2, denoting the respective day, month, and year on which the book was due to be returned.</p><p><strong>Constraints</strong></p><ul><li>1 ≤ d1,d2 ≤ 31</li><li>1 ≤ m1,m2 ≤ 12</li><li>1 ≤ y1,y2 ≤ 3000</li><li>It is guaranteed that the dates will be valid Gregorian calendar dates.</li></ul><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*RHctT-KOQkB4J_Jm-QWSug.png" /></figure><p>In this algorithm, we first check if the month and the year returned is equal to the month and the year of the due date, and if the the d1 is greater than d2. If it is, we return the difference of d1 and d2 and multiply it by 15. The next thing we check is if the year matches, but the months don’t. If it does, we take the difference of the months and multiply it by 500. Next, we check if just the years are different, if so, we return the flat fine of 10000. Finally if the book is returned before or the day of the due date, we return 0 because there is no fine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bf2aba1141e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grading Students Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/grading-students-solution-in-javascript-e74f22d474ae?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/e74f22d474ae</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 19 Nov 2021 02:21:07 GMT</pubDate>
            <atom:updated>2021-11-19T02:21:07.136Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p>HackerLand University has the following grading policy:</p><ul><li>Every student receives a grade in the inclusive range from 0 to 100.</li><li>Any grade less than 40 is a failing grade.</li></ul><p>Sam is a professor at the university and likes to round each student’s grade according to these rules:</p><p>If the difference between the grade and the next multiple 5 of is less than 3, round grade up to the next multiple of 5.<br>If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.</p><p><strong>Examples</strong></p><ul><li>grade = 84 round to 85(85–84 is less than 3)</li><li>grade = 29 do not round (result is less than 40)</li><li>grade = 57 do not round (60–57 is 3 or higher)<br>Given the initial value of grade for each of Sam’s n students, write code to automate the rounding process.</li></ul><p><strong>Function Description</strong></p><p>Complete the function gradingStudents in the editor below.</p><p>gradingStudents has the following parameter(s):</p><ul><li>int grades[n]: the grades before rounding</li></ul><p><strong>Returns</strong></p><ul><li>int[n]: the grades after rounding as appropriate</li></ul><p><strong>Input Format</strong></p><p>The first line contains a single integer, n, the number of students.<br>Each line i of the n subsequent lines contains a single integer, grades[i].</p><p><strong>Constraints</strong></p><ul><li>1 ≤ n ≤ 60</li><li>0 ≤ grades[i] ≤100</li></ul><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nW-g9eb8nKunWJ7gEnvxvg.png" /></figure><p>In this algorithm, we return the map of the grades array. If a grade satisfies the condition of the grade being greater or equal to 38 and the remainder of the grade divided by 5 is greater than or equal to 3, we round the grade up to the multiple of 5. Otherwise, we return grade.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e74f22d474ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day Of The Programmer Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/day-of-the-programmer-solution-in-javascript-92fc2239f2f2?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/92fc2239f2f2</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Fri, 12 Nov 2021 03:51:13 GMT</pubDate>
            <atom:updated>2021-11-12T03:51:13.090Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p>Marie invented a <a href="https://en.wikipedia.org/wiki/Time_machine">Time Machine</a> and wants to test it by time-traveling to visit Russia on the <a href="https://en.wikipedia.org/wiki/Day_of_the_Programmer">Day of the Programmer</a> (the 256th day of the year) during a year in the inclusive range from 1700 to 2700.</p><p>From 1700 to 1917, Russia’s official calendar was the <a href="https://en.wikipedia.org/wiki/Julian_calendar">Julian calendar</a>; since 1919 they used the <a href="https://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a> system. The transition from the Julian to Gregorian calendar system occurred in 1918, when the next day after January 31st was February 14th. This means that in 1918, February 14th was the 32nd day of the year in Russia.</p><p>In both calendar systems, February is the only month with a variable amount of days; it has 29 days during a leap year, and 28 days during all other years. In the Julian calendar, leap years are divisible by 4; in the Gregorian calendar, leap years are either of the following:</p><ul><li>Divisible by 400.</li><li>Divisible by 4 and not divisible by 100.</li></ul><p>Given a year, y, find the date of the 256th day of that year according to the official Russian calendar during that year. Then print it in the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.</p><p>For example, the given year = 1984. 1984 is divisible by 4, so it is a leap year. The 256th day of a leap year after 1918 is September 12, so the answer is 12.09.1984.</p><p><strong>Function Description</strong></p><p>Complete the dayOfProgrammer function in the editor below. It should return a string representing the date of the 256th day of the year given.</p><p>dayOfProgrammer has the following parameter(s):</p><ul><li>year: an integer</li></ul><p><strong>Input Format</strong></p><p>A single integer denoting year y.</p><p><strong>Constraints</strong></p><ul><li>1700 \le y \le 2700</li></ul><p><strong>Output Format</strong></p><p>Print the full date of Day of the Programmer during year yin the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.</p><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rtapbdwMtifjwbh_2xGlw.png" /></figure><p>So with this algorithm we first check if the year is 1918, if so we return the string “26.09.1918” because 1918 was a special day for programmers. If not, we check if is is divisible by 4 and greater than the year 1914, if the year was divisible by 400, or if the year is divisible by 4, but not divisible by 100, then if so we return the string “12.09” + year. Any other case, we return the string “13.09” + year.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92fc2239f2f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apple and Orange Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/apple-and-orange-solution-in-javascript-f43dcfa98640?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/f43dcfa98640</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Thu, 04 Nov 2021 15:33:28 GMT</pubDate>
            <atom:updated>2021-11-04T15:45:04.070Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p>Sam’s house has an apple tree and an orange tree that yield an abundance of fruit. Using the information given below, determine the number of apples and oranges that land on Sam’s house.</p><p>In the diagram below:</p><ul><li>The red region denotes the house, where is s the start point, and t is the endpoint. The apple tree is to the left of the house, and the orange tree is to its right.</li><li>Assume the trees are located on a single point, where the apple tree is at point a, and the orange tree is at point b.</li><li>When a fruit falls from its tree, it lands d units of distance from its tree of origin along the x-axis. *A negative value of d means the fruit fell d units to the tree’s left, and a positive value of d means it falls d units to the tree’s right. *</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/0*3elKdx-kqTREKXLB.png" /></figure><p>Given the value of d for m apples and n oranges, determine how many apples and oranges will fall on Sam’s house (i.e., in the inclusive range [s,t])?</p><p>For example, Sam’s house is between s = 7 and t = 10. The apple tree is located at a = 4 and the orange at b = 12. There are m = 3 apples and n = 3 oranges. Apples are thrown apples = [ 2,3, -4] units distance from a, and oranges = [ 3,-2,-4] units distance. Adding each apple distance to the position of the tree, they land at [ 4 +2, 4 +3, 4 + -4] = [6, 7, 0]. Oranges land at [ 12 + 3, 12 + -2, 12 + -4] = [15,10,8]. One apple and two oranges land in the inclusive range 7– 10 so we print</p><pre>1<br>2</pre><p><strong>Function Description</strong></p><p>Complete the countApplesAndOranges function in the editor below. It should print the number of apples and oranges that land on Sam’s house, each on a separate line.</p><p>countApplesAndOranges has the following parameter(s):</p><ul><li>s: integer, starting point of Sam’s house location.</li><li>t: integer, ending location of Sam’s house location.</li><li>a: integer, location of the Apple tree.</li><li>b: integer, location of the Orange tree.</li><li>apples: integer array, distances at which each apple falls from the tree.</li><li>oranges: integer array, distances at which each orange falls from the tree.</li></ul><p><strong>Input Format</strong></p><p>The first line contains two space-separated integers denoting the respective values of s and t.<br>The second line contains two space-separated integers denoting the respective values of a and b.<br>The third line contains two space-separated integers denoting the respective values of m and n.<br>The fourth line contains m space-separated integers denoting the respective distances that each apple falls from point a.<br>The fifth line contains n space-separated integers denoting the respective distances that each orange falls from point b.</p><p><strong>Constraints</strong></p><ul><li>1 ≤ s,t,a,b,m,n ≤ 10⁵</li><li>-10⁵ ≤ d ≤ 10⁵</li><li>a &lt; s &lt; t &lt;b</li></ul><p><strong>Output Format</strong></p><p>Print two integers on two different lines:</p><ol><li>The first integer: the number of apples that fall on Sam’s house.</li><li>The second integer: the number of oranges that fall on Sam’s house.</li></ol><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ranDRA9Tu4z3GvM80-x3Rg.png" /></figure><p>In this algothrim, we set up two let variables called appleCount and orangeCount. They will represent the apples and orange the fall within the area of the house. We use two for loops to iterate throughout the two arrays of apples and oranges. Within this loops, we will check if they fall within the boundary of the house, and if it does, we add to the count. Finally, we will console.log both results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f43dcfa98640" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sherlock and Squares Solution in Javascript]]></title>
            <link>https://travisslee223.medium.com/sherlock-and-squares-solution-in-javascript-96b205a647f5?source=rss-98480780c320------2</link>
            <guid isPermaLink="false">https://medium.com/p/96b205a647f5</guid>
            <dc:creator><![CDATA[Travis Lee]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 21:42:52 GMT</pubDate>
            <atom:updated>2021-10-28T21:42:52.175Z</atom:updated>
            <content:encoded><![CDATA[<p>by Travis Scott Lee</p><p>Watson likes to challenge Sherlock’s math ability. He will provide a starting and ending value that describe a range of integers, inclusive of the endpoints. Sherlock must determine the number of square integers within that range.</p><p><strong>Note</strong>: A square integer is an integer which is the square of an integer, e.g. 1,4,9,16,25.</p><p><strong>Example</strong></p><p>a = 24</p><p>b = 29</p><p>There are three square integers in the range: 25, 36 and 49. Return 3.</p><p><strong>Function Description</strong></p><p>Complete the squares function in the editor below. It should return an integer representing the number of square integers in the inclusive range from a to b.</p><p>squares has the following parameter(s):</p><ul><li>int a: the lower range boundary</li><li>int b: the upper range boundary</li></ul><p><strong>Returns</strong></p><ul><li>int: the number of square integers in the range</li></ul><p><strong>Input Format</strong></p><p>The first line contains q, the number of test cases.<br>Each of the next q lines contains two space-separated integers, a and b, the starting and ending integers in the ranges.</p><p><strong>Constraints</strong></p><p>1 ≤ q ≤ 100</p><p>1 ≤ a ≤ b ≤ 10⁹</p><p><strong>Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMXmuCFb8GwwuEArrmzMaw.png" /></figure><p>For this algo, we round up the product of a and round down the product of b is because to optimize the run time of the algo. If we scanning thousands of number between one to ten thousand, the algo is going to take a while to check if it is a square root or not. Then, we set a for loop to check the range between the rounded square roots of a and b. For even integer we pass in the loop the counter will go up. Realizing now, the if statement within that for loop is redundant.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96b205a647f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>