While getting groceries, I saw this endcap for cotton candy-flavored energy drink. The “XBox controller as phone” pose is silly, but it also reminded me of a phone I’d wanted way back in the early 2000s: the Nokia N-Gage.
Released in 2003 (in the pre-smartphone era, back when mobile phones sported a lot of dedicated buttons), the N-Gage was a phone-meets-handheld gaming device. IGN summed it up best as “a bad console filled with bad games,” and it didn’t help that the speaker and microphone were mounted on its side. In order to use it as a phone, you’d have to hold it like this — a position that would come to be known as sidetalking:
Sidetalking looked silly, so soon there were sidetalking photos featuring people using the N-Gage while making silly faces…
…followed by people ditching the N-Gage altogether and opting to take sidetalking photos with any old electronic thing, turning it into a full-blown meme:
I even got on the fun, using my device of choice:
In case you’re wondering, I’m not really pining for the N-Gage anymore. My iPhone 13 Pro is a decent gaming phone, and on the Android side, I’ve got a Nubia Redmagic 6R that plays Genshin Impact rather nicely.
Right up to its cancellation, the Elon Musk / Twitter deal increasingly looked like Robot Chicken’s parody of the Darth Vader / Lando Calrissian deal:
In the previous installment in the How to solve coding interview questions series, I showed you my Python solution for the challenge “Find the first NON-recurring character in a string,” which is a follow-up to the challenge “Find the first recurring character in a string.”
A couple of readers posted their solution in the comments, and I decided to take a closer look at them. I also decided to write my own JavaScript solution, which led me to refine my Python solution.
“CK”’s JavaScript solution
The first reader-submitted solution comes from “CK,” who submitted a JavaScript solution that uses sets:
// JavaScript
function findFirstNonRepeatingChar(chars) {
let uniqs = new Set();
let repeats = new Set();
for (let ch of chars) {
if (! uniqs.has(ch)) {
uniqs.add(ch);
} else {
repeats.add(ch);
}
}
for (let ch of uniqs) {
if (! repeats.has(ch)) {
return ch;
}
}
return null;
}
The one thing that all programming languages that implement a set data structure is that every element in a set must be unique — you can’t put more than one of a specific element inside a set. If you try to add an element to a set that already contains that element, the set will simply ignore the addition.
In mathematics, the order of elements inside a set doesn’t matter. When it comes to programming languages, it varies — JavaScript preserves insertion order (that is, the order of items in a set is the same as the order in which they were added to the set) while Python doesn’t.
CK’s solution uses two sets: uniqs
and repeats
. It steps through the input string character by character and does the following:
- If
uniqs
does not contain the current character, it means that we haven’t seen it before. Add the current character touniqs
, the set of characters that might be unique. - If
uniqs
contains the current character, it means that we’ve seen it before. Add the current character torepeats
, the set of repeated characters.
Once the function has completed the above, it steps through uniqs
character by character, looking for the first character in uniqs
that isn’t in repeats
.
For a string of length n, the function performs the first for
loop n times, and the second for
loop some fraction of n times. So its computational complexity is O(n).
Thanks for the submission, CK!
Dan Budiac’s TypeScript solution
Dan Budiac provided the second submission, which he implemented in TypeScript:
// TypeScript
function firstNonRecurringCharacter(val: string): string | null {
// First, we split up the string into an
// array of individual characters.
const all = val.split('');
// Next, we de-dup the array so we’re not
// doing redundant work.
const unique = [...new Set(all)];
// Lastly, we return the first character in
// the array which occurs only once.
return unique.find((a) => {
const occurrences = all.filter((b) => a === b);
return occurrences.length === 1;
}) ?? null;
}
I really need to take up TypeScript, by the way.
Anyhow, Dan’s approach is similar to CK’s, except that it uses one set instead of two:
- It creates an array,
all
, by splitting the input string into an array made up of its individual characters. - It then creates a set,
unique
, using the contents ofall
. Remember that sets ignore the addition of elements that they already contain, meaning thatunique
will contain only individual instances of the characters fromall
. - It then goes character by character through
unique
, checking the number of times each character appears inall
.
For a string of length n:
- Splitting the input string into the array
all
is O(n). - Creating the set
unique
fromall
is O(n). - The last part of the function features a find() method — O(n) — containing a filter() method — also O(n). That makes this operation O(n2). So the whole function is O(n2).
Thanks for writing in, Dan!
My JavaScript solution that doesn’t use sets
In the meantime, I’d been working on a JavaScript solution. I decided to play it safe and use JavaScript’s Map
object, which holds key-value pairs and remembers the order in which they were inserted — in short, it’s like Python’s dictionaries, but with get()
and set()
syntax.
// JavaScript
function firstNonRecurringCharacter(text) {
// Maps preserve insertion order.
let characterRecord = new Map()
// This is pretty much the same as the first
// for loop in the Python version.
for (const character of text) {
if (characterRecord.has(character)) {
newCount = characterRecord.get(character) + 1
characterRecord.set(character, newCount)
} else {
characterRecord.set(character, 1)
}
}
// Just go through characterRecord item by item
// and return the first key-value pair
// for which the value of count is 1.
for (const [character, count] of characterRecord.entries()) {
if (count == 1) {
return character
}
}
return null
}
The final part of this function takes an approach that’s slightly different from the one in my original Python solution. It simply goes through characterRecord
one key-value pair at a time and returns the key for the first pair it encounters whose value is 1.
It remains an O(n) solution.
My revised Python solution
If I revise my original Python solution to use the algorithm from my JavaScript solution, it becomes this:
# Python
def first_non_recurring_character(text):
character_record = {}
# Go through the text one character at a time
# keeping track of the number of times
# each character appears.
# In Python 3.7 and later, the order of items
# in a dictionary is the order in which they were added.
for character in text:
if character in character_record:
character_record[character] += 1
else:
character_record[character] = 1
# The first non-recurring character, if there is one,
# is the first item in the list of non-recurring characters.
for character in character_record:
if character_record[character] == 1:
return character
return None
This is also an O(n) solution.
Previously in this series
- How to solve coding interview questions: The first NON-recurring character in a string
- Coding interview questions: “First recurring character” in Swift
- How to solve coding interview questions: The first recurring character in a string
- I Has the Dumb (or: How I Embarrassed Myself in My Interview with Google) — from way back in 2013
Here’s an excerpt from the current version of my resume (yes, my resume’s under version control). Note the highlighted entry:
The entry is for Hyve, the startup and application that my StartupBus team built when I rode in 2019. Hyve was a service that let you create “burner” email addresses that relayed email to and from your real email address, allowing you to safely subscribe to services and avoid getting marketing spam or safely communicate with people whom you might not completely trust.
We did all right in the end, landing in the runner-up slot:
…but the real wins came a little bit afterward when I was interviewing for developer and developer relations jobs a couple of weeks afterward. StartupBus makes for a good story, and in a job interview, it’s the story that “sells” you.
After all, StartupBus is a hackathon where you’re challenged to come up with:
- A startup business
- and an application that supports that business
- on a bus
- in three days.
This intrigued the people who interviewed me, which led me to talk about the decisions that shaped the business, which in turn shaped the software. I detailed the challenges of writing business plans and software on a bus, a rumbling, rolling office space with spotty internet access, unreliable power, and the occasional engine breakdown. I also talked about dealing with the compressed timeframe and a few of the tricks we used to get around the limited time, which included getting help from our professional network, taking advantage of crowdsourcing services, and using our media contacts. My StartupBus story played a key part in convincing prospective employers that they wanted to hire me.
StartupBus Florida will depart Tampa, Florida on Wednesday, July 27 and make a 3-day trip with interesting stops and challenges along the way. It will arrive in Austin, Texas on the evening of Friday, July 29, where it will meet with teams from 6 other buses:
On Saturday, July 30, all the teams will assemble at a venue in Austin for the semifinals. Every team will pitch in front of a set of semifinals judges. By the end of the day, a handful of finalists will emerge (Hyve was one of six finalists in 2019).
Those finalists will then go on to the finals, which will take place on Sunday, July 31. They’ll pitch again (and if they’re smart, they’ll have spent the night before reworking their pitch and application) in front of the finals judges, who will select the winner and runners-up.
If you participate in StartupBus, you will come out of it a different person. You will pitch your startup at least a dozen times (and yes, everyone pitches — not just the marketing people, but the creatives and developers, too). You will work on product design. You will work on marketing. You will work on code. And you’ll do it all under far-from-ideal circumstances. StartupBus is a crash course in guerrilla entrepreneurship, and it’s an experience that will serve you well — especially during these economically upside-down times.
And you’d better believe that you’ll have stories to tell, and they’ll help you stand apart from the crowd.
Want to ride StartupBus later this month?
You’ll need to apply on the StartupBus site, and you’ll need an invite code. Use mine: JOEY22, which will tell them that I sent you.
Here’s the list of tech, entrepreneur, and nerd events for Tampa Bay and surrounding areas for the week of Monday, July 11 through Sunday, July 17, 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.
Want to find out more?
- Check out the StartupBus site
- My post, I’m going on StartupBus again, and you should too!
Want to join the bus? Drop me a line!
This week’s events
Monday, July 11
Group | Event Name | Time |
---|---|---|
Young Professionals Networking JOIN in and Connect! | In person at Fords Garage St Pete | 11:00 AM |
Option Trading Strategies (Tampa Bay area) Meetup Group | July 11th: Option Trading Strategies Meetup (Online) | 11:00 AM |
JobFairX | Tampa Job Fair – Tampa Career Fair | 11:00 AM – 2:00 PM EDT |
Christian Professionals Network Tampa Bay | Live Online Connection Meeting- Monday | 11:30 AM |
Professional Business Networking with RGAnetwork.net | Virtual Networking Lunch | 11:30 AM |
Entrepreneurs & Business Owners of Sarasota & Bradenton | Virtual Networking Lunch Monday | 11:30 AM |
Thinkful Tampa | Thinkful Webinar || Intro to Data Analytics: SQL Fundamentals | 12:00 PM – 1:30 PM EDT |
Tampa Financial Freedom Meetup Group | How You Can Get Your Business In The Media For FREE! | 2:30 PM |
SCIPS, a 50+ Tampa Bay Singles Club | EUCHRE, Rummy Q and other Board Games for ENTHUSIASTIC GAME PLAYERS | 4:00 PM |
Entrepreneurs & Startups – Bradenton Networking & Education | David Wilkinson: Creating Momentum for Business Growth | 5:30 PM |
Critical Hit Games | MTG: Commander Night | 6:00 PM |
Tampa Bay Tabletoppers | Monday Feast & Game Night | 6:00 PM |
BerLagmark – Sarasota Amtgard | Monday Night Fighter Practice! | 6:00 PM |
Beginning Web Development | Weekly Learning Session | 6:00 PM |
Toastmasters, Division D | ACE Advanced Toastmasters 3274480 | 6:00 PM |
Board Game Meetup: Board Game Boxcar | Weekly Game Night! (Lazy Moon Location) | 6:00 PM |
Thinkful Tampa | Thinkful Webinar || What Tech Career Is Right For Me? | 6:00 PM – 7:30 PM EDT |
Toastmasters District 48 | Wesley Chapel Speaks Toastmasters | 6:30 PM |
Toastmasters District 48 | North Port Toastmasters Meets Online!! | 6:30 PM |
PWOs Unite! | Tampa PWOs Meetup | 7:00 PM |
Tampa Bay Gaming: RPG’s, Board Games & more! | Flesh and Blood at Hammerfall Games and Collectibles | 7:00 PM |
Tampa Bay Real Estate Investors Club (TampaBayREIC) | TampaBayREIC – Brandon Subgroup | 7:00 PM |
Brandon WordPress Meetup | TBA: Regular WordPress Meeting | 7:00 PM |
St. Petersburg Crypto Investors and Miners Club | Club DAO | 7:00 PM |
Tampa – Sarasota – Venice Trivia & Quiz Meetup | Trivia Night – Motorworks Brewing Smartphone Trivia Game Show | 7:00 PM |
Orlando Stoics | ONLINE: “Epicureanism” (Part 2) | 7:00 PM |
Central Florida AD&D (1st ed.) Grognards Guild | World of Greyhawk: 1E One-Shots | 7:30 PM |
North Florida Stock Investing Education | North Florida Chapter Model Investment Club | 7:30 PM |
Thinkful Tampa | Thinkful Webinar || Intro to HTML & CSS: Build Your Own Website | 9:00 PM – 10:30 PM EDT |
Tampa / St Pete Business Connections | Monday Virtual Business Introductions | 11:30 PM |
Tuesday, July 12
Wednesday, July 13
Thursday, July 14
Group | Event Name | Time |
---|---|---|
Young Professionals Networking JOIN in and Connect! | Tampa Young Professionals Virtual Networking Thursday Morning All WElCOME | 7:30 AM |
Pasco County Entrepreneurs & Business Owners All Welcome | Happy Hangar Early Bird Professionals Networking | 7:30 AM |
Professional Business Networking with RGAnetwork.net | Wesley Chapel/Lutz networking breakfast | 7:30 AM |
Wesley Chapel, Trinity, New Tampa, Business Professionals | Business Over Breakfast ~ Happy Hangar IN PERSON JOIN US! | 7:30 AM |
Professional Business Networking with RGAnetwork.net | Virtual Networking Breakfast Thursday’s | 7:30 AM |
Toastmasters District 48 | Toast of the Bay Weekly Toastmasters Meeting – Join Us! | 7:30 AM |
Network Professionals Inc. of South Pinellas (NPI) | NPI Bayview Chapter – Exchange Qualified Business Referrals | 7:30 AM |
BNI Professional Alliance – Business Referral Group | BNI Professional Alliance – A Business Referral Group | 8:00 AM |
Business Networking Weekly Meeting for Local Professionals | Business Networking for Local Professionals | 8:00 AM |
Masterminds of Orlando Leads Group | Masterminds of Orlando Leads Group | 8:30 AM |
TampaBayNetworkers | Suncoast Networkers | 8:30 AM |
Orlando Melrose Makers | In-Person: Makerspace Open Lab | 10:30 AM |
Hyperledger Tampa | How to Operate and Extend the Hyperledger Besu Ethereum Client | 11:00 AM |
The 360 Exchange – Waterford | The 360 Exchange – Waterford Networking | 11:30 AM |
Thinkful Tampa | Thinkful Webinar || Learn Data Analytics With Thinkful | 12:00 PM – 1:30 PM EDT |
Tampa Bay Tech Career Advice Forum | Lunch & Learn: Salary Negotiations | 12:00 PM |
Tampa Cybersecurity Training | Lunch & Learn: Salary Negotiations | 12:00 PM |
Tampa Bay Professionals (IT, Sales, HR & more) | Handling Objections | 1:00 PM |
Bradenton Photo Group | Lightroom Sessions – Edits and Catalogs | 5:00 PM |
Lean Startup Orlando | LSO&TrueFit Summer Social | 5:30 PM |
Thinkful Tampa | Thinkful Webinar || Data Science vs. Data Analytics | 6:00 PM – 7:30 PM EDT |
Brandon and Seffner area AD&D Group | 1st ed AD&D Campaign. | 6:00 PM |
Remote Collective ST. PETE | Social Club For Remote Workers | Drinks @ Grand Central Brewhouse | 6:00 PM |
Brown Girls’ Book Club and Hangout Group | Homegoing | 6:00 PM |
Sunshine Social Deduction Gaming | Social Game Night @ Hourglass Brewery | 7:00 PM |
Meet Me In The Metaverse | Meet Me In The Metaverse – Florida’s First Web3 Metaverse Meetup | 7:00 PM |
Real Life Trading – Tampa FL | RLT Tampa Stock Trading Meetup | 7:00 PM |
Tampa Hackerspace | Woodshop Tool Sign Off-Jointer, Planer, & Bandsaw (Members Only) | 7:00 PM |
Financial Secrets for Wealth Accumulation Personal/Business | Financial Wealth Secrets to turn your Debts into Wealth | 8:00 PM |
Thinkful Tampa | Thinkful Webinar || Intro To Data Analytics: Tableau Basics | 9:00 PM – 10:30 PM EDT |
Friday, July 15
Saturday, July 16
Sunday, July 17
Do you have any events or announcements that you’d like to see on this list?
Let me know at joey@joeydevilla.com!
Join the mailing list!
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!
How computer networking works
Funny and true: