Posts

Showing posts from September, 2022

Tandem Bicycle Coding Problem

Image
      For this weeks assignment I decided to do one of the longer coding challenges. This one is called tandem bicycle. A tandem bike is a bike that has 2 or more seats on it with every rider pedaling. If there are 2 people riding one bike than the speed of the bike will be determined by the faster peddler and the slower peddler will be ignored. The way this challenge works is you are given an 2 arrays with integer values that represent 2 different groups of riders. One of the groups are red riders and the other group is blue riders. Every index inside of the arrays represent one rider and the value inside of that index determines the speed of the rider. The higher the speed the faster the rider can peddle. You are also given another variable called target which is a boolean and will either be False or True. If the target is True then we are trying to find a way to pair every blue rider with every red rider to find the fastest combination of riders. If target is False we are trying to

Binary Tree Challenges

Image
             For this week I decided to step into more complicated challenges that take use of a binary tree. A binary tree is one of the most common algorithms that is used in coding interviews so its important to understand the ins and outs of it. The first image above is a visual image of what the algorithm actually looks like. Think of every circle as a node or an object that is attached to our algorithm. The very first node on the top is called the root node. Every node after that are children nodes and children nodes can also have children nodes as well. When a node is not pointing to anything like the 4, 7, 13 they are called lead nodes. In this case we can take a guess that the values that were put in were in order [8,3,10,14,13,1,6,4,7]. This might be incorrect but its just a guess to explain what is happening in this image. The first value added would be the 8 and it becomes the root node because its the very first node in our tree. Then we add three. If three is less than 8

Coding Challenges Week 2

Image
    For this week I decided to write solve two different coding problems. As the semester goes on and I get better using Python tools I will attempt to do more every week. The first problem is called minimum waiting time. You are given a list of integers that represent the amount of time in seconds it will take for queries to run. What we are trying to do is give the minimum amount of time it will take to run all those queries. The amount of time a query takes to run is adding all the values before it. If the query is running for the first time its time will be 0 seconds since there are no queries before it. If we are given a list of     [3,2,1,2,6] the minimum waiting time in seconds would be 17 seconds. That is because the time would be calculated as (0) + (1) + (1+2) + (1+2+2) + (1+2+2+3) = 17.     The first steps in solving this problem is to create a variable to hold the total seconds and sort the array from minimum to maximum order. We sort the array because if you are given a li

First Non Repeating Character Coding Challenge

Image
      For this semester I will be solving different coding problems that are commonly asked in developer interviews. I have applied for several developer internships this last month and need to get prepared on solving these problems along with being able to explain my solutions. The first problem I did this week is called first non repeating character.     The goal of this problem is to be able to write a function that takes in a string. You want to be able to return the index of the first non repeating character in the string. For example if you are give the string "aabbcddee" the first non repeating character would be the letter c. In this case you would return the index number 4. If you were given the string "aabbccddee" you would return -1. This is because part of the problem is if there is not a non repeating character is a string then we just return -1.     The way I go about these problems is I try to break it down into smaller problems. Lets just say we have