In this post I will not be solving a problem, instead I will be talking about something I learned by reading chapter 7 Design a Unique ID Generator in Distributed Systems in the book System Design Interview by Alex Wu.
The idea of a unique ID is a requirement in most distributed systems. In my case, some years ago I was developing a storage server and needed to name the objects of different types and sizes a client might wish to store and of course, at some later point in time, retrieve. The idea of a file system path did not make sense because it would be nearly impossible to keep the same immutable configuration among many distributed systems with a huge capacity. Continue reading “Design Unique ID Generator in Distributed Systems”
Good day! Hope you are doing well. Today is July 13th, 2021. We are approaching midsummer. Not sure where time is going.
As I mentioned a few posts ago, I attempted some daily problems posted by LeetCode. At this time I am somewhat busy so I have missed a few. Hopefully in a month or two I will have enough time to work on a problem a day; at least the easy and medium. The others may take a couple days. Continue reading “Find Peek Element”
Good morning! It is once again Saturday morning during the COVID-19 pandemic. Today is March 13, 2021 and the sun is shining in the Twin Cities of Minneapolis and St. Paul. The forecast calls for the temperature to get up to 58F. For this time of the year it is welcomed. Tomorrow it will be a little cooler and daylight savings time starts at 02:00 AM when the clocks spring forward to 03:00 AM. Tomorrow we lose one hour.
A week or so ago I was talking with an engineer about merging a set of sorted arrays. I also generated the post Merge Sorted Array which probably motivated the exchange. If you take a look at the last post, the idea was to merge two sorted arrays. The obvious next step is to consider multiple sorted arrays of the same or different lengths. In that post we considered two approaches. In the first one we add all the elements from both arrays into a priority queue. We then populate the result array with the elements being removed from the priority queue. Continue reading “Merge K Sorted Arrays”
It is Thursday and for a while it was snowing. We received a couple inches of fresh snow. Will see what the weather brings us this weekend. I believe Sunday is going to be the coldest day of this winter so far. We might hit -20F. That said; it appears that the weather forecast changes multiple times a day.
Today my wife was not at home for lunch. I prepare toasts with avocado. Put a dab of butter on a couple slices of ciabatta bread, place them on a cooking sheet and into the oven (set at 400F) they went for about seven minutes. While that was going on, I took out from the freezer a Butter Chicken with Basmati rice tray from Trader Joe’s. As soon as the toast was done I swapped the tray with the chicken. The instructions called for 25 minutes so I consumed the toast with avocado and went back to my office. Continue reading “Dot Product of Two Sparse Vectors in Java”
Good evening. It is Tuesday January 12, 2021. We are still in the middle of the COVID-19 pandemic. For some reason vaccination in the USA and specific in Minnesota is not progressing at a reasonable pace. Hopefully when all political issues clear, things will start progressing at a better pace. Continue reading “Balance a Binary Search Tree”
Good day! It is Thursday morning and it is a typical gloomy and cold winter day in the Twin Cities of Minneapolis and St. Paul. The good thing is that is Thursday. One more day to go to and we can start enjoying the weekend. For most of us the weekend will be 2-days long. It is different from the past two weekends in which most people enjoyed 3 or 4 days off work.
Due to COVID-19 my wife and I just leave home for grocery shopping and healthcare appoints when needed. The good thing is that vaccination has started in the USA and hopefully in a few more months most of us will be vaccinated and can start getting back to normal. We all will see what happens. Continue reading “Contains Duplicate”
Today is Wednesday morning. It seems that the high temperature for the day will be 31F. Better than yesterday but my wife and I live in the Twin Cities of Minneapolis and St. Paul and winters are rather harsh in this part of the country.
This morning I decided to move from solving Facebook technical interview questions to Microsoft. I will try to solve a couple problems a day if time allows. Will see how it goes. My source will be LeetCode. At some point I might switch to HackerRank.
Without further ado, let’s get to the problem at hand. Continue reading “1-bit and 2-bit Characters”
Good day! My wife and I had a good weekend. Hopefully you did also.
As I was generating this post I noticed that my blog has passed the 5,000 subscribers!!! Thanks to all of you. If you have suggestions on how to improve, I would be interested in learning your thoughts. Once again; thanks to all of you.
Over the weekend my wife and I prepared Oxtail Stew. It was very yummy! We coated the oxtail parts with some olive oil. On a baking tray we placed the pieces. We put them in an oven at 550F. As soon as the pieces started to get cooked, we flipped them and put them back in the oven to repeat the process. We were looking for nice color all around.
While in the oven we chopped onions, celery and some carrots to make our mirepoix. We did not add oil, salt, pepper or any other condiments.
We took the oxtail, the mirepoix and a couple cups of chicken broth and put them in an electric pressure cooker for 90 minutes. Oxtail contains a lot of fat , which like many other things in life, it is good with moderation, so it is better to let it melt away and when done, remove most of it. Continue reading “Add Strings”
Hi everybody! Hope you are doing well. It is Thursday evening and I do not know where the week went. We have one more day before the next weekend!
I was looking at singly linked lists in LeetCode and decided to tackle problem 328. Odd Even Linked List. If interested take a look at the requirements.
Given a singly linked list,
group all odd nodes together followed by the even nodes.
Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place.
The program should run in O(1) space complexity and O(nodes) time complexity.
o The relative order inside both the even and odd groups should remain as it was in the input.
o The first node is considered odd, the second node even and so on ...
o The length of the linked list is between [0, 10^4].
We are given a singly linked list and are asked to separate the nodes that are at odd indices from the ones at the even indices. The first node would be at position 1, the second node at position 2, the third note at position 3 and so on. The values in the node are of no interest. Continue reading “Odd Even Linked List”
It is a Monday morning and it is garbage collection day so I had to put out on the driveway both bins. The company that provides our development with the service collects every week both garbage and recycle bins. All previous companies that I am familiar with collect garbage every week and recycle every other week. To be honest with you, my wife and I would be fine with recycling once a month and if it was not for the potential for smell during summer, garbage every other week.
Earlier this morning, I saw in my inbox a recommendation for a problem from HackerRank named Sherlock and GCD which maybe solved with a Dynamic Programming approach. Continue reading “Sherlock and GCD”