Have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (ie. “lane borrowed” would result in true because there is exactly three characters between a and b). Otherwise return the string false. I have tried to avoid using a for loop for this […]

Before posting the solutions on the blog, I solve them on Coderbyte. Thus, when I have started writing the post, I have observed that my initial solution makes use of two for loops. That means the initial solution has a quadratic time complexity – O(N^2), which is not desired. However, the new solution is making […]

The Ex Oh Coderbyte challenge checks if there is an equal number of x’s and o’s in a given string. The requirements of the problem are as follows: Have the function ExOh(str) take the str parameter being passed and return the string true if there is an equal number of x‘s and o‘s, otherwise return the string false. Only these two letters will be […]

The next challenge asks us to write a function that takes a number and returns the factorial of it. The text below is taken straight from Coderbyte: Have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it. For example: if num = 4, then your program should return (4 * 3 * 2 * 1) = 24. […]

I want to start this post by mentioning that I have moved from LeetCode to Coderbyte for a while. The reason for doing so is because Coderbyte offers a discount on the premium plan for students. The premium membership offers access to all the coding challenges (200+), and it offers step-by-step solutions as well. Also, […]

The challenge I am going to explain is the Jewels and Stones challenge, which, by the way, is a concise one. The description of the problem is as follows: You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want […]

Another challenge I have enjoyed solving is finding all the unique email addresses. I have just copied and pasted the description from LeetCode, as it does a better job explaining the problem than me. Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local […]

The next challenge I am going to explain is how to reverse the words in a String. This one is a little bit tricky because we have to take into account the whitespace and the initial order of the words. Below we have the challenge: Given a string, you need to reverse the order of […]

Today I am going to talk about how I have implemented the lowercase problem from LeetCode. To have all the information in one place and to avoid moving from one page to another, I have copied the problem below. Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example […]