Balance a Binary Search Tree

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”

Contains Duplicate

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”

1-bit and 2-bit Characters

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”

Add Strings

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”

Odd Even Linked List

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.

Constraints:

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”

Sherlock and GCD

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”

Simple and Second Web Servers in Node.js

I am about to call it a day. It is dark and cold (25 F) in the Twin Cities of Minneapolis and St. Paul. I am in my office attempting to finish this post while my wife is upstairs in the living room wrapped in a blanket. Tomorrow morning we will wake up to a balmy 12 F. What else can I say?

I am reading and experimenting with the content of the book “Get Programming with Node.js” by Jonathan Wexler. I am currently on page 55. Expect to be done with towards the end of next month. At that time I will switch to experiment with Deno. Then I will move on to generate and post a first pass of a storage server. It should be a lot of fun. Continue reading “Simple and Second Web Servers in Node.js”

Least Recently Used Cache – Java

It is a gloomy Sunday in the Twin Cities of Minneapolis and St. Paul. The current temperature is 23F. The forecast calls for snow. Looks like a perfect day to stay home and enjoy some good food and watch a couple movies. It is a thoughtful wishing, but at 09:15 AM my wife and I will be heading to Trader Joe’s in St. Paul to get some veggies and bread. Yesterday we made strawberry ice cream. My son requested a few servings for his family. We will be delivering it later this morning. Hopefully the roads will not be too slippery. Continue reading “Least Recently Used Cache – Java”

Coin Change

Hope you are doing well and keeping safe! Last evening my wife and I, after stopping a movie we were watching on Netflix, went to bed. It was still snowing on and off. We were both very tired. Today when we were having breakfast, we noticed that the driveway and path to our door had been cleared of snow. We did not hear a thing. That confirms we were really tired last evening.

One of my best friends (have two sent me the link to the article “Top Universities Took Billions in Unreported Foreign Funds, U.S. Finds”, by the Wall Street Journal. The article is quite interesting. It shows how China is gifting money (there are no free lunches) to top USA learning institutions (mostly Ivy League universities) in order to take / steal intellectual property, allowing China to avoid developing technologies at much higher costs. This was discovered due to the fact that those same institutions have been forgetting to pay the associated gift / donation taxes. Shame on you Cornell University! Continue reading “Coin Change”

Backspace String Compare

It is a Saturday morning in the Twin Cities of Minneapolis and St. Paul. As we have been doing for a few months, my wife and I drove to the Costco store in Minneapolis, met with our son and went grocery shopping. Today we were not able to find Three Berry Blend bags. We got separate bags of strawberries and blueberries. Our son will stop later today at the Costco in Eagan. MN and will see if he is able to find a couple bags of mixed berries and a box of pens that we forgot while in Minneapolis.

This week I watched the Association for Computing Machinery (ACM) webinar “Lessons from COVID-19: Efficiency vs. Resilience” by Moshe Y. Vardi. It seems that the webinar is only accessible if you are an ACM member, which I am. I enjoyed the point he made of efficiency versus resilience not only at the software but also at the political level. At no point he mentioned politicians or political parties. In my opinion, it is a very good one-hour webinar worth your time. Continue reading “Backspace String Compare”