Hi Friends,
Welcome to the 7th edition of the Polymathic Engineer newsletter. I hope you all are having a few relaxing days-off work or school.
I love the holiday season because it's an opportunity to spend time with family and show people how much you care about them. But the holidays are also an excellent time for reflection.
It is always helpful to stop and think about the past year, both what went well and what didn't, and then use that to decide how we want our next year to be. Indeed, this is the period most people use to fix their goals for the coming year.
This is why I want to share a practical approach I used to set goals: SMART goals.
What are SMART goals
SMART stands for: Specific, Measurable, Achievable, Relevant, Time-bounded.
The best way to understand the meaning of each part of the acronym is by proceeding with examples.
Specific
A goal must be specific. The more the goal is straightforward, the better it is. For example, if your goal is to find a new job, don't target a generic job. Instead, target a particular position at a specific company. Likewise, if your goal is to learn data structures, choose as a goal to learn tree-based data structures.
Measurable
It's important to know when you've accomplished a goal. For example, the goal is to get a job at XY company. In that case, it is measurable by evaluating if you get the job. Likewise, your goal is to learn a new programming language. In that case, it is measurable by considering how much code you write using that language.
Achievable
A realistic goal shall be achievable with your resources. It would help if you had honest self-reflection, analyzing how much work you have to do and how much effort you can put in. For example, it is probably not achievable to get a job at Google in 1 month by preparing for only 1 hour per week.
Relevant
Motivation is important. You need to care about a goal to achieve it. For example, if you're looking for a job right now, it's relevant to you to study for interviews. If you need a programming language to finish a project, it's appropriate for you to learn it.
Time-bounded
You'll keep putting it off if you don't have a deadline for your goal. This is crucial for success. It helps you say how much you need to work daily to achieve your goal.
Why using SMART goals
There are 3 crucial reasons why I found SMART goals helpful:
they increase my psychological response to the goals
they increase the probability I follow through with the goals
they give me a structured way to assess if my goals are appropriate
A last important thing I’d like to add is that once you define a high-level big SMART goal, it’s beneficial to break it down into smaller and smaller pieces. My strategy is usually to set smaller SMART goals until I have ultimately broken down all the work in 1 hour to 1-day blocks.
Coding Challenge
The coding challenge of last week was Simplify Path. Given a string representing an absolute Unix path, the problem asks to convert it to the simplified canonical path.
An absolute path has the following format:
starts with a single slash '/' and each part is separated by a '/'
multiple consecutive slashes are treated as a single slash
each part can contain a period referring to the current directory
each part can contain a double period referring to the parent directory
A canonical path has the following format:
end without slash '/'
each part is separated only by a single slash '/'
only contains the directories without a single or double period
This is a classic problem where understanding the right data structure to use can quickly bring a good solution. There are several scenarios to handle, but the enlightening one is the double period.
When a double period occurs, the previous part of the path needs to be discarded. If we put all the parts of the path in a data structure in left to right order, this means that the last inserted part needs to be removed. This is what a stack allows us to do efficiently.
So the algorithm is composed of the following step steps:
split the input path using a single slash '/' as the delimiter
push all the parts of that path in a stack
pop the last inserted part when a double period occurs
build the canonical path iterating through the stack from bottom to top
Some programming languages have a stack implementation that allows iterating a stack from bottom to top. For the other programming languages, a second stack can be used to reverse the element in the first stack. As an alternative, it can be used a double-ended queue that always allows iterating of its elements from front to back.
The time complexity of this approach is O(N), where N is the number of characters in the original path. Indeed, the split of the input path into components and the processing of each component are both O(N) operations. The space complexity is O(N) because of the stack.
Here is the code for the solution:
The next coding challenge will be Middle of the linked list.
Interesting Tweets of the week
The debate about monoliths vs. microservices is a classic in software architecture. My opinion is that it's not necessary to use microservices from scratch if a monolith fits all your requirements. And if the monolith is modular, it will be also easier to switch to microservices in case this is necessary. This thread gives a nice introduction to the concept of modular monoliths
![Twitter avatar for @mjovanovictech](https://substackcdn.com/image/twitter_name/w_96/mjovanovictech.jpg)
![Image](https://substackcdn.com/image/fetch/w_600,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fpbs.substack.com%2Fmedia%2FFkklrprXwAEeFoM.jpg)
Technical writing is an important skill for developers. This tweet links to a great article explaining how to start with technical writing.
![Twitter avatar for @TheAnkurTyagi](https://substackcdn.com/image/twitter_name/w_96/TheAnkurTyagi.jpg)
![](https://substackcdn.com/image/fetch/w_600,h_314,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0499e665-39c5-4866-9556-731d98aa723e_1200x630.jpeg)
Greetings
I've almost completed one year of consistently writing and sharing technical content every week. A lot of positive stuff happened thanks to this, and starting this newsletter was the most beneficial side effect.
I thank you all again for your support, and I wish you all a happy new year. I'm looking forward the send the first newsletter issue of the next year in the 2nd week of January.