blackprogramming
blackprogramming
blackprogramming
10 posts
Don't wanna be here? Send us removal request.
blackprogramming · 7 years ago
Text
Coding Interview Warmup: “Not”
I almost didn’t post this because it’s a really simple problem, and I don’t feel like I’ve posted anything challenging on this blog. I’m doing this because I’ve been really lazy practicing recently, so maybe this will get me going.
Given a string, return a new string where "not " has been added to the front. However, if the string already begins with "not", return the string unchanged.
Examples:
not_string('candy') → 'not candy' not_string('x') → 'not x' not_string('not bad') → 'not bad'
Credit: CodingBat
So yes, this isn’t the hardest problem in the world, but I did have to use Python (something I’m not totally familiar with) to formulate my solution. See my answer HERE.
2 notes · View notes
blackprogramming · 7 years ago
Text
Things I should be doing:
Tumblr media
Things I’m not doing:
Tumblr media
792 notes · View notes
blackprogramming · 7 years ago
Text
Coding Interview Question: Sum of Two
You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.
Example
For a = [1, 2, 3], b = [10, 20, 30, 40], and v = 42, the output should be sumOfTwo(a, b, v) = true.
Credit: CodeFights
------
Now, this question is seemingly easier than the last; HOWEVER, I am posting it here because it was a bit tricky to figure out how to optimize the brute force solution.
To start off, a dictionary in Python is essentially a hash table in data structures. A hash table is a data structure that stores items in key-value pairs. To access items in a hash table takes O(n) time, so it is very efficient. While I wouldn’t say to solve EVERY coding interview problem using a hash table, many people find them to be very useful in most situations.
Now, on to the solution! 
-------
Brute Force: The brute force solution is a bit obvious in this case, and it takes O(n^2) time. For each item in array a, add it to each item in array b and see if the sum is equal to v. 
This approach passes all of the sample test cases; however, when it comes to complex scenarios, this fails to find a solution efficiently. This is where our optimized solution comes in.
Optimized Approach: The optimized approach takes O(n) time, and involves using a hash table (go figure!). Think of it like this: if you have a target, for example, 45, and you currently have 13, all you need to complete the equation is a 32. Knowing that a 32 exists SOMEWHERE in the second array is enough to say addition is possible.
In that case, we place all the elements in array b inside of a dictionary, and only iterate through array a. During each iteration, we subtract the current item from the goal (in our example, 45) to get a remainder. From this, we check our hash table to see if the remainder exists. If it does, we can return true. If not, we must continue our iteration. At the end of it all, if our remainder never exists in our hash table, we return false.
See my Python (optimized and brute force) implementation HERE!
If you have another way to solve this, let me know!
0 notes
blackprogramming · 7 years ago
Text
Coding Interview Question: Rotate Image
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix = [  [1,2,3],  [4,5,6],  [7,8,9] ], rotate the input matrix in-place such that it becomes: [  [7,4,1],  [8,5,2],  [9,6,3] ]
Example 2:
Given input matrix = [  [ 5, 1, 9,11],  [ 2, 4, 8,10],  [13, 3, 6, 7],  [15,14,12,16] ], rotate the input matrix in-place such that it becomes: [  [15,13, 2, 5],  [14, 3, 4, 1],  [12, 6, 8, 9],  [16, 7,10,11] ]
--------------
Alright, y’all -- let me be real with you. I have been staring at this question for about an hour and a half, and I’ve got nothing. I took a look at a couple of solutions to understand the best approach to rotating the image in place, but they go over my head. Maybe my brain is just fried.
Here’s the best solution that I’ve found so far: 
youtube
I’m not currently near paper or pen at the moment to walk myself through it line by line, so, once I understand what she’s proposed, I will type up her solution in Python, upload it to GitHub, and edit this post to share with you!
If you have any idea of how to go about this, I’d love to hear it!
2 notes · View notes
blackprogramming · 7 years ago
Text
Coding Interview Question: The World Cup is here!
Given the surname of a player, determine how hard it is to pronounce. We assume that the difficulty of the surname is the maximum number of consecutive consonants in it.
Example
For surname = "Blaszczykowski", the output should be hardSurname(surname) = 6;
For surname = "Papastathopoulos", the output should be hardSurname(surname) = 2.
Credits: CodeFights
-----
When I first attempted this problem, I was very confused because it was hard for me to grasp what a “consecutive consonant” was. This is definitely a point I would clarify with a interviewer prior to starting to solve the problem. 
I came up with a O(n) solution (hopefully -- correct me if I’m wrong!) which iterates through the given string and keeps track of the highest number of consecutive consonants. You can think of it as a “max number in array” problem.
You can see my code with comments HERE.
0 notes
blackprogramming · 7 years ago
Text
Incoming -- Coding Interview Series!
Hey guys!
I haven’t been very consistent, but I’m trying to become much more active because (*drumroll*) -- it’s almost interview season!
I have an interview with a tech company for the upcoming summer, and I really want to nail it! I think it’d be beneficial to go through this journey together, so, just as before, I will post coding questions, my thought process, and the question answers on this blog.
All code will be available through my GitHub as well. I’m excited to get this thing rolling! 
1 note · View note
blackprogramming · 7 years ago
Text
I’m an introvert.
and it sucks (sometimes!).
When it comes to navigating the tech space, a lot of people here share this similar quality.
Being able to stand out from everyone else mainly lies in how you communicate in this field. In the midst of awkward coders and uncoordinated students, I’ve had to learn (much to my dislike) how to talk to people.
One of the things I HATE is talking on the phone. Unless I’m talking to a good friend, the inability to see physical reactions drives me crazy. Unfortunately, a lot of companies do phone interviews and screenings. Imagine how many times it took for me to finally nail down that process. Lots and lots of practice.
Even in the workplace, I’m very cringy. Constantly overthinking interactions with coworkers, avoiding people, and masking my facial reactions to my surroundings. I can’t help it.
The biggest thing is to fake it til’ you make it. You don’t have to sacrifice who you are and mold yourself to be what people want; BUT be able to operate in both spaces.
0 notes
blackprogramming · 8 years ago
Text
a quick word on technical interviews
Let me be honest here: I truly suck at technical interviews.
I usually can quickly solve problems when I’m on my own in front of my computer, but, once you get a much more experienced stranger on the other line quietly critiquing my thought process, suddenly everything gets a lot harder.
This semester, I completely bombed my interviews with Amazon and Facebook (Google is another story for another day and IBM is TBA). Due to such a busy schedule, I didn’t adequately prepare, but, I think that even if I had, my general navigation of technical interviews is horrendous. 
If you haven’t had a technical interview, here’s the standard format:
Introduction from the technical interviewer.
Why do you want to work for Company XYZ? (optional)
Alright, let’s get started – here’s a seemingly simple problem. You must solve it as I breathe down your neck. Didn’t study trees or recursion? I guess you’re just screwed** :)
Feel free to ask me questions, but don’t ask me too many or else you’ll seem clingy and dependent.
Also, you have ~30-45 minutes to get it done, but I won’t tell you that; you should know this already.
The awkward silence on the line? Find a way to ignore that. 
Also, while you’re thinking in your mind, please think out loud. I like to hear your thoughts =))))))
Whether you passed the interview or completely bombed it, I’ll give you the chance to ask me some questions. 
**Yeah, so if you plan on interviewing with Facebook, please remember to review trees and recursion. May or may not have experienced this exact moment.
I don’t want to make it sound as though conquering a coding interview is impossible, but getting good at such environments truly is a skill on its own. You MUST prepare. There is no way to just waltz in and out of a tech interview without some kind of prep. I truly feel as though I could have done better if I had more time to do so.
Here are some useful websites I use to prepare for my interviews:
LeetCode
Interviewing.io
CodingBat
CodeFights
Cracking the Coding Interview Solutions
0 notes
blackprogramming · 8 years ago
Text
Interview Practice Problem #1: Strings
Problem Description: 
Given a string s, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.
Example:
For s = "abacabad", the output should be firstNotRepeatingCharacter(s) = 'c'. There are 2 non-repeating characters in the string: 'c' and 'd'. Return c since it appears in the string first.
Try solving the problem first before looking at my problem analysis & solution!
Problem Analysis:
The first thing that I try to do when I look at a problem is see if there is a corresponding data structure that can get me closer to the solution. 
Bells starting ringing for me when I read “first non-repeating character.” To me, that meant that a set** could be useful because, ultimately, we are not looking for non-unique characters.
**In case you are not aware, a set is a data structure that holds unique items. For example, if the series of numbers [2, 3, 4, 4, 1, 2] were inserted into a set, the set would contain [2, 3, 4, 1]. 
On second glance, if the duplicates did not exist in the string, it would be hard to determine which character(s) is NOT repeating. Therefore, I decided to work within the existing string and use string methods to construct a solution. 
Here is the final solution + explanations on GitHub.
Do you have another (or even better) way to solve this problem? Let me know!
3 notes · View notes
blackprogramming · 8 years ago
Text
I’m Lissy.
Hello everyone!
I’m a third-year software engineering major in university. I’ve been tumblr-ing for a while now, but I really have a passion for what I’m studying and would like to share my experiences as a black female in the technology industry as well as some tips that have allowed me to experience and discover some pretty cool opportunities.
Additionally, I would love to provide any programming help to anyone who would live to delve into this field as well as go through some sample coding interview problems found on the web and elsewhere. I am not an expert by any means, so I am interested in learning as well!
Feel free to follow -- I’m just getting started, so expect some more content in the next couple of days! 
3 notes · View notes