#OneYearCodingPlan - Big O, Arrays and Strings - by Anjali Viramgama - The Startup - Medium
#OneYearCodingPlan - Big O, Arrays and Strings - by Anjali Viramgama - The Startup - Medium
#OneYearCodingPlan - Big O, Arrays and Strings - by Anjali Viramgama - The Startup - Medium
#OneYearCodingPlan : Month 1
In this article, we’ll discuss time & space complexity, arrays, and strings, for coding
interviews. Before we begin, I’d like to discuss the structure that I’ll try to follow in my
blogs.
Format:
1. Topic overview and Learning Timeline to be followed.
3. Interview tips.
Disclaimer — One month is the worst possible deadline you can have for these topics,
you have to wrap this up in a month(remember sticking to the plan?), and you can
(and should) try to finish early, by spending more time per day, especially on
weekends, and jumping to the next topic, especially if you have a coding background
and feel confident about these topics. The OneYearPlan can be scrunched down to a
12-week plan if you have prior experience or tighter deadlines. However, don’t try to
rush if you have time, you should preferably do projects, research, or gain experience
on the side if you have extra time.
Source — websystemer.no
It is extremely important to understand time and space complexities because they help
you judge how good your solution is, and brainstorm about if and how you can make it
better.
GeeksForGeeks
HackerEarth
Interview Cake
Why is the constant dropped off? An important concept, well explained here.
Practice Questions:
Read these examples first. (GeeksForGeeks again)
After these questions, you should be able to know the basics. This is a trivial topic, but I
am assuming you have basic knowledge of recursion, etc. If not, you can spend some
extra time in understanding it. After this, whenever you solve any question in the
future, you should be sure what its space and time complexity is, and you’re good to go.
Here’s a question for you after you think you are ready:
Find the time complexity of the c++ function, quuz() , which is invoked by the
In python:
Interview Tips:
The coolest part about Big O is, most companies ask the same question about it:
“What is the time and space complexity of the solution you just coded?” & “Can you
make it better?”
Whenever you are asked a question by an interviewer, always start talking out loud
about your thoughts/solutions. Start by stating out the brute force solution, and then
move on to better solutions, and always include the time and space complexity of
the solution while discussing it, that leaves a good impression. Then start coding the
best solution you can think of.
Another reason why this topic is important is when you participate in coding contests,
you might get a “terminated due to timeout” error, which is mostly caused when they
are expecting a better solution from you in terms of the Big O.
Companies like Google, Bloomberg, etc. pushed me to solve the same question in
various different ways, with different complexities. In my first round with Google,
when I solved the interview question and we had time left, the interviewer pushed me
to think of different ways to solve the same question/use different data structures,
though the solution I had given was optimal. Recruiters generally are more interested
in the way you approach the problem and the different solutions you can come up with
than you just solving the question presented to you.
Arrays and Strings:
Learning the syntax, methods, and reading — 1 day
If easy problems seem too easy for you, always switch to the next step, and use all the
extra days to solve more hard problems. Aim to spend at least 3–5 hours a day,
regardless of how busy you might be.
GeeksForGeeks
TutorialsPoint
join(MyArrayList b)- Add all elements of ArrayList b behind the current elements in the
current object, and return the entire structure.
Practice Questions:
String Manipulation
Arrays
More Arrays
These resources are just suggested in case you don’t know where to start. If you are a
user of any other platforms (CodeChef/ Code Forces etc.) use them. I’ve never
personally used them, so I don’t want to preach what I don’t practice, but they are
awesome platforms from what I’ve heard as well. What’s important is that you solve a
vast variety of questions, regardless of the source.
Whenever you think you are ready, you should try these questions (you are not allowed
to look up their solutions, if you have issues solving these, try practicing other
problems more.) Also, do these on a whiteboard. These are not necessarily hard
questions, the catch is to be able to do them on a whiteboard.
You have probably heard of balanced brackets problem, Given a string which
consists of only brackets “{“, “}”, “(“, “)”, “[“, “]”, write a program to examine
whether the brackets are balanced.
Example:
Solve the above question with string manipulation( not a stack, use only strings).
Lastly, build a function that randomly selects and returns an element from an array
with a probability proportional to its value. For example, in [1,2,3], the probability
of getting 3 should be 1/2, the probability of 2 should be 1/3, and 1 should be 1/6.
Interview Tips:
Arrays and Strings are vastly underestimated, but most interviews I have given ask
tricky questions from this topic especially in their first round. Arrays and Strings will
always be a subpart of the complex problems you’ll solve later, and having a solid base
here is necessary for success in the upcoming topics.
Feel free to reach out to me for queries, constructive criticism is always welcome! I had
a lot of people ask me to provide resources, so I tried to do that here. If you have any
other suggestions, ping me on my social media!
Thanks,
Anjali Viramgama.
LinkedIn | Instagram