David Castañeda and Justin Linn coding our StartupBus 2019 app Hyve, on StartupBus Florida, July 2019. Tap to view at full size.
We’re about a week and a half away from Wednesday, July 27th, when four buses — one from here in Tampa Bay, along with buses from Cincinnati, Silicon Valley, and Mexico City — will start a three-day journey to Austin Texas.
During those three days, the buses’ riders will be participating in a hackathon, where they’ll be challenged to:
Come up with an idea for a startup business
Develop a plan for that startup
Work on a pitch for that startup
Develop the software for that startup
We’ve got a lot of idea, business, and design people on this year’s StartupBus Florida, but we need more developers.
This is a call to developers in the Tampa Bay area and beyond to join StartupBus Florida. You don’t have to be from Tampa Bay or even Florida to ride StartupBus Florida — you just have to be up for a hackathon, road trip, and personal growth all rolled up together!
You don’t have to be an genius-level coder; you just have to know how to code!
Tracy Ingram, Rina Bane, and David Castañeda coding our StartupBus 2019 app Hyve on StartupBus Florida, July 2019. Tap to view at full size.
I’ve participated in and organized plenty of hackathons, and I’ve seen so many people resist participating because they believe that they’re not good enough coders. I think that if you can code, you’re good enough — and more importantly, participating in a hackathon can make you a better coder!
Here’s the thing: in a hackathon, you’re not coding a full-fledged app in its final form. You’re building a prototype application that demonstrates what would be possible if you had the time and resources to build a full-fledged app in its final form. You’re building the thing that makes the difference between a startup idea and a startup reality.
If you’re unsure about joining StartupBus Florida as a coder, ask yourself these questions:
Can I program a basic web, mobile, or desktop application that can respond to user input?
Can I make that application save data to and retrieve data from a database?
Can I make that application make use of an API?
Can I figure out new things by asking questions and Googling?
If you can answer “yes” to questions 1 and 4, as well as answer “yes” to either questions 2 or 3 (or both), you should join StartupBus Florida as a coder!
Can you code a back end in Express, Flask, or Laravel? You should code on StartupBus Florida.
Can you code a front end in React, Next, Vue, Angular, Svelte or any other framework? You should code on StartupBus Florida.
“Okay, I’m convinced. When does everything take place?”
The bus ride: StartupBus starts with a 3-day bus ride that runs from the morning of Wednesday, July 27 to the early evening on Friday, July 29 when it arrives in Austin, Texas.
The pitch competition: The final two events happen in the destination city, with the semifinals on Saturday, July 30 and the finals on Sunday, July 31.
Travel back home: You’re responsible for your trip home from Austin. I’m flying back on Monday, August 1.
Okay, maybe coding interviews aren’t that bad. But they’re close!
If you’re interviewing for a position that requires you to code, the odds are pretty good that you’ll have to face a coding interview. This series of articles is here to help you gain the necessary knowledge and skills to tackle them!
Over the next couple of articles in this series, I’ll walk you through a classic computer science staple: linked lists. And by the end of these articles, you’ll be able to handle this most clichéd of coding interview problems, satirized in the meme below:
You’ve probably seen the ads for AlgoExpert with the woman pictured above, where she asks you if you want a job at Google and if you know how to reverse a linked list.
But before you learn about reversing linked lists — or doing anything else with them — let’s first answer an important question: what are they?
What are linked lists?
A linked list is a data structure that holds data as a list of items in a specific order. Linked lists are simple and flexible, which is why they’re the basis of many of the data structures that you’ll probably use in your day-to-day programming.
Linked list basics
Nodes
The basic component of a linked list is a node, which is diagrammed below:
A node in a linked list. Tap to view at full size.
In its simplest form, a node is a data structure that holds two pieces of information:
data: This holds the actual data of the list item. For example, if the linked list is a to-do list, the data could be a string representing a task, such as “clean the bathroom.”
next: A linked list is simply a set of nodes that are linked together. In addition to the data it holds, a node should also know where the next node is, and that’s what its next property is for: it points to the next item in the list. In languages like C and Go, this would be a pointer, while in languages like C#, Java, JavaScript, Kotlin, Python, and Swift, this would be a reference.
Here’s a Python implementation of a node. We’ll use it to implement a linked list:
# Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
def __str__(self):
return f"{self.data}"
With Node defined, you can create a new node containing the data “Hello, world!” with this line of code:
new_node = Node("Hello, world!")
To print the data contained inside a node, call Node’sprint() method, which in turn uses the value returned by its __str__() method:
print(new_node)
# Outputs “Hello, world!”
Assembling nodes into a linked list
You create a linked list by connecting nodes together using their next properties. For example, the linked list in the diagram below represents a list of the first four letters of the alphabet: a, b, c, and d, in that order:
A linked list of nodes. Tap to view at full size.
The diagram above features the following:
Four nodes, each one for a letter in the list.
A variable called head, which is a pointer or reference to the first item in the list. It’s the entry point to the list, and it’s a necessary part of the list — you can’t access a linked list if you can’t access its head.
An optional variable called tail, which is a pointer or reference to the last item in the list. It’s not absolutely necessary, but it’s convenient if you use the list like a queue, where the last element in the list is also the last item that was added to the list.
Let’s build the linked list pictured above by putting some nodes together:
# Python
# Let’s build this linked list:
# a -> b -> c -> d
head = Node("a")
head.next = Node("b")
head.next.next = Node("c")
head.next.next.next = Node("d")
That’s a lot of nexts. Don’t worry; we’ll come up with a better way of adding items to a linked list soon.
Here’s an implementation that creates the same list but doesn’t rely on chaining nexts:
# Python
# Another way to build this linked list:
# a -> b -> c -> d
head = Node("a")
node_b = Node("b")
head.next = node_b
node_c = Node("c")
node_b.next = node_c
node_d = Node("d")
node_c.next = node_d
To see the contents of the list, you traverse it by visiting each node. This is possible because each node points to the next one in the list:
Of course, the code above becomes impractical if you don’t know how many items are in the list or as the list grows in size.
Fortunately, the repetition in the code — all those prints and nexts — suggests that we can use a loop to get the same result:
# Python
current = head
while current is not None:
print(current)
current = current.next
Here’s the output for the code above:
a
b
c
d
A linked list class
Working only with nodes is a little cumbersome. Let’s put together a linked list class that makes use of the Node class:
# Python
class LinkedList:
def __init__(self):
self.head = None
def __str__(self):
if self.head is None:
return('Empty list.')
result = ""
current_node = self.head
while current_node is not None:
result += f'{current_node}\n'
current_node = current_node.next
return result.strip()
def add_last(self, data):
new_node = Node(data)
# If the list is empty,
# point `head` to the newly-added node
# and exit.
if self.head is None:
self.head = new_node
return
# If the list isn’t empty,
# traverse the list by going to each node’s
# `next` node until there isn’t a `next` node...
current_node = self.head
while current_node.next:
current_node = current_node.next
# If you’re here, `current_node` is
# the last node in the list.
# Point `current_node` at
# the newly-added node.
current_node.next = new_node
This LinkedList class has the following members:
head: A property containing a pointer or reference to the first item in the list, or None if the list is empty.
__init__(): The class initializer, which initializes head to None, meaning that any newly created LinkedList instance is an empty list.
__str__(): Returns a string representation of the contents of the linked list for debugging purposes. If the list contains at least one item, it returns the contents of the list. If the list is empty, it returns the string Empty list.
add_last(): Given a value, it creates a new Node containing that value and adds that Node to the end of the list.
With this class defined, building a new list requires considerably less typing…
# Python
list = LinkedList()
list.add_last("a")
list.add_last("b")
list.add_last("c")
list.add_last("d")
…and displaying its contents is reduced to a single function call, print(list), which produces this output:
a
b
c
d
Coming up next:
JavaScript implementations
Adding an item to the start of a linked list
Finding an item in a linked list
Will you ever use a linked list, and why do they ask linked list questions in coding interviews?
Here’s the list of tech, entrepreneur, and nerd events for Tampa Bay and surrounding areas for the week of Monday, July 18 through Sunday, July 24, 2022.
Every week, with the assistance of a couple of Jupyter Notebooks that I put together, I compile this list for the Tampa Bay tech community.
As far as event types go, this list casts a rather wide net. It includes events that would be of interest to techies, nerds, and entrepreneurs. It includes (but isn’t limited to) events that fall under the category of:
Programming, DevOps, systems administration, and testing
Tech project management / agile processes
Video, board, and role-playing games
Book, philosophy, and discussion clubs
Tech, business, and entrepreneur networking events
Toastmasters (because nerds really need to up their presentation game)
Sci-fi, fantasy, and other genre fandoms
Anything I deem geeky
By “Tampa Bay and surrounding areas”, this list covers events that originate or are aimed at the area within 100 miles of the Port of Tampa. At the very least, that includes the cities of Tampa, St. Petersburg, and Clearwater, but as far north as Ocala, as far south as Fort Myers, and includes Orlando and its surrounding cities.
StartupBus 2022 will depart from Tampa Bay!
If you’re looking for an adventure, a chance to test your startup skills, and an experience that will make your résumé stand out, join me on StartupBus Florida, which departs Tampa Bay on July 27, when it sets course for Austin, Texas!
On this three-day journey, “buspreneurs” will form teams, create a business idea, build a software demo for that idea, and develop pitches for that idea. When they arrive in Austin, they’ll spend two days pitching their startups to a panel of judges.
I was a “buspreneur” on StartupBus Florida in 2019, the last time the event took place, and our team made it to the finals and got the runner-up position. This time, I’m a “conductor” — one of the coaches on the bus — and our team is here to help you rise to the challenge.
If you’d like to get this list in your email inbox every week, enter your email address below. You’ll only be emailed once a week, and the email will contain this list, plus links to any interesting news, upcoming events, and tech articles. Join the Tampa Bay Tech Events list and always be informed of what’s coming up in Tampa Bay!
We’ve heard enough about hucksters who’ve opened Tampa Bay offices, such as the one-click wonder whose office didn’t even last a year:
Creative Commons photo by Web Summit. Tap to see the source.
…and the other well-funded one who just declared Chapter 11…
Creative Commons photo by Web Summit. Tap to see the source.
…but the real Tampa Bay tech stars won’t be sitting in comfortable offices or mouthing empty platitudes on a fancy stage. They’ll be working on their business idea for three days on a bus.
StartupBus
StartupBus 2012. Photo via Creative Loafing / Arielle Stevenson.
StartupBus is an annual hackathon that takes place on a bus. Its participants — called buspreneurs — hop on a bus, form teams, and try to come up with a startup and the software that supports it as the bus makes a three-day trip to the destination city, where they will pitch their startups to a panel of judges.
The riders on the combined Florida and D.C. StartupBus buses in 2019. Photo by Nick Price.
StartupBus started in 2010, and there’s been a bus from the Tampa Bay area since 2011. Tampa Bay StartupBus alumni have gone on to found companies, build great careers, and generally have an impact on the local tech scene. While some are content to pull marketing stunts and lap up the local media attention, “The Other Bay Area’s” true tech heroes and crafting code, building businesses, and fostering community.
I was on the before, and I’ll be on the bus again
Team Hyve from StartupBus Florida 2019: Tracy Ingram, David Castañeda, Yours Truly, Rina Bane, Justin Linn. Photo via 88degrees / Tracy Ingram.
I was a buspreneur in 2019, and my teammates — Rina Bane, David Castañeda, Tracy Ingram, and Justin Linn — made it to the finals, where we got the runner-up position.
This year, after the 2020 / 2021 COVID-19 hiatus, the bus is back, and this time, I’m a coach — or as we say on StartupBus, a conductor — and along with my fellow conductors Mandy Minor and Evan Thacker, I plan to help this year’s buspreneurs build their startups and hopefully make it to the finals.
Want to get on the bus?
Me on the bus on Day 1, July 2019. Photo by Joey deVilla.
The bus departs Tampa on Wednesday, July 27th and arrives in the destination city, Austin, on Friday, July 29th. Then we’ll be in Austin for 2 days: the semi-finals on Saturday, July 30th and the finals on Sunday, July 31st. I’m flying back home on Monday, August 1st.
It’s not too late to register! We need more people on the bus — especially programmers. If you can build even a basic web, mobile, or desktop application, we need you on the Florida bus. But if your skills are in other areas: product management or design, marketing, user interface / experience, and so on, we need you too!
If you have a company and want it to get the kind of press attention that questionable one-click shopping and shady crypto bros have been getting, you should sponsor StartupBus! StartupBus gets national attention, and as a sponsor, we’ll make sure to sing your praises and let the world know that your company truly cares about making “The Other Bay Area” a great place for techies — the economic engines of the future — to live, work, and play.
Hey, techies from Tampa Bay and beyond — are you interested in any of the following:
StartupBus
The Metaverse
Web3
We’re holding an online meetup, Meet Me in the Metaverse, on Thursday, July 14th from 7:00 p.m. to 8:00 p.m. in a web-based virtual reality space to discuss the topics above, and you’re all invited to join us! Register here to attend the event.
This isn’t going to be a Zoom or Teams meeting, but a VR meeting. And don’t worry — you won’t need VR gear — any computer with a browser will do. I took the meetup’s VR environment for a test drive, and it presented itself like a first-person shooter, minus the shooting, where you use the W, A, S, and D keys to move and the mouse to change the direction you’re facing.
Here are a couple of screenshots of what I saw during my quick exploratory run:
My first view of the Metaverse venue. Tap to view at full size.
Walking into the lobby. Tap to view at full size.
The view from the top floor. Tap to view at full size.
I’ll be there — join me! Once again, that’s Thursday, July 14th, from 7:00 p.m. to 8:00 p.m., and you can register here.
In previousposts, I’ve presented Python, JavaScript, and TypeScript solutions for the coding interview challenge: “Write a function that returns the first NON-recurring character in a given string.” In this post, I’ll show you my solution in Swift.
Here’s a table that provides some sample input and corresponding expected output for this function:
If you give the function this input…
…it should produce this output:
aabbbXccdd
X
a🤣abbbXcc3dd
🤣
aabbccdd
null / None / nil
The algorithm
I’ve been using an algorithm that takes on the problem in two stages:
In the first stage, the function steps through the input string one character at a time, counting the number of times each character in the string appears in a “character record”. Because we’re looking for the first non-recurring character in the input string, the order in which data is stored in the character record is important. It needs to maintain insertion order — that is, the order of the character record must be the same order in which each unique character in the input string first appears.
For example, given the input string aabbbXccdd, the function should build a character record that looks like this:
Character
Count
a
2
b
3
X
1
c
2
d
2
Given the input string a🤣abbbXcc3dd, it should build a character record that looks like this:
Character
Count
a
2
🤣
1
b
3
X
1
c
2
3
1
d
2
Given the input string aabbccdd, it should build a character record that looks like this:
Character
Count
a
2
b
2
c
2
d
2
Once the function has built the character record, it’s time to move to the second stage, where it iterates through the character record in search of a character with a count of 1, and:
If the function finds such a character, it exits the function at the first such occurrence, returning that character. For the input string aabbbXccdd, it returns X, and for the input string a🤣abbbXcc3dd, it returns 🤣.
If the function doesn’t find any characters with a count of 1, it exits the function, having gone through every character in the character record, returning a null value (which in the case of Swift is nil).
Using a Swift OrderedDictionary
The character record is the key to making the algorithm work, and the key to the character record is that must be an ordered collection. If I add a, b, and c to the character record, it must maintain the order a, b, c.
This isn’t a problem in Python. While Python dictionaries have traditionally been unordered, as of Python 3.7, dictionaries maintain insertion order. In the previousarticles covering this coding interview question, my Python solutions used a regular Python dictionary.
Because JavaScript runs in so many places in so many versions, I decided not to trust that everyone would be running a later version, which preserves insertion order. In the previous article, I wrote a JavaScript solution that implemented the character record using Map, a key-value data structure that keeps the items stored in the order in which they were inserted.
Swift’s built-in Dictionarydoes not keep the items in any defined order. Luckily, the Swift Collections package provides OrderedDictionary, which gives us both key-value storage and insertion order.
You’ll need to add Swift Collections to your project in order to use it. To do this, select File → Add Packages…
The dialog box for adding packages will appear:
Do the following:
Enter swift-collections into the search field.
Select swift-collections from the package list.
Click Add Package.
You’ll be presented with a list of products within the Swift Collections package:
For this exercise, you’ll need only OrderedCollections, so check its box and click Add Package, which will add the package to your project.
Implementing the solution
Now we can implement the solution!
// We need this for `OrderedDictionary`
import OrderedCollections
func firstNonRecurringCharacter(text: String) -> String? {
var characterRecord = OrderedDictionary<Character, Int>()
for character in text {
if characterRecord.keys.contains(character) {
characterRecord[character]! += 1
} else {
characterRecord[character] = 1
}
}
for character in characterRecord.keys {
if characterRecord[character] == 1 {
return String(character)
}
}
return nil
}
characterRecord, which keeps track of the characters encountered as we go character by character through the input string, is an OrderedDictionary. Note that with Swift, which is both statically and strongly typed, we need to specify that characterRecord’s keys are of type Character and its values are Ints.
After that, the implementation’s similar to my Python and JavaScript versions.