Inorder Successor in BST

As you might know, I work on 2-hour blocks. At the end of a block I go upstairs and get something to drink. I chat with my wife for a few minutes and then head downstairs to my office for the next 2-hour block. I just got back and was about to start a new task when I noticed that I had not finished a post I started earlier today. Will finish it right now and will post it. Then I will move on to the next task.

This morning we woke up to a balmy 11 F degrees. The good thing about the COVID-19 pandemic is that we can work from home and do not have to deal with the car and parking. I fully understand that is nothing to what other people are going through. Hopefully we will be getting a vaccine in the next few months. If all goes well we might start going back to something that resembles how things were before the pandemic. Continue reading “Inorder Successor in BST”

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”

Slow Sum

I am tired. It has been a long week. I got lots of stuff done. It is already dark. The good thing is that today is December 11. On December 21 winter starts. That is only ten days away. After December 21 the days start getting longer in the northern hemisphere!!!

Just to push a little and get one more problem in before the end of the workweek, I decided to work on Slow Sum. This is just one problem in a set of about a couple dozen in the Facebook web site. Continue reading “Slow Sum”

Largest Triple Products

Once again it is Friday during the COVID-19 pandemic. Not much to say due to the fact that outside work not much is changing. So far the COVID-19 vaccine development programs appear to be moving forward. Earlier this week UK started vaccinating people in nursing homes.

One of the sons of my best friend was married last year and moved to the UK. His wife and he had a baby boy about three months ago. My friend’s son, his spouse and newborn arrived earlier today for a month long visit. Hope they have a great time. Hopefully a month from now with the help of vaccines things will be getting better all over the world. Continue reading “Largest Triple Products”

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”

Reverse Operations

In the past three days the high for the day has been in the mid to upper 40s. Since late fall a considerable amount of leaves has been accumulating in the entrance at home. Yesterday just before lunch I picked up the dead leaves. This morning some started to collect. I guess this is due to the orientation and shape of the entrance.

Last evening I also read an interesting article titled After Centuries, a Seemingly Simple Math Problem Gets an Exact Solution by Steve Nadis published in Quanta Magazine. Apparently a German mathematician named Ingo Ullisch figured out an exact solution for a problem. Good for him. What I liked more than the problem or its solution is the last paragraph in the article. In my humble opinion, this reaffirms the fact that reading and experimenting is the best way to learn. Continue reading “Reverse Operations”

Queue Removal in Java

Good day! Hopefully your day has started on the right note. Last evening my wife and I watched Ava on Netflix. I like movies with spies and action. Perhaps the plot could have been more realistic and credible. We gave the movie a thumb up.

Earlier today I decided to work on the Facebook coding practice problem Queue Removals. The problem provides a single sample test. In addition, when you run your code, it will be checked against two tests. There are no additional hints. There are no additional tests. Continue reading “Queue Removal in Java”

Balance Brackets

It is pitch dark in the Twin Cities of Minneapolis and St. Paul. Before calling it a day I decided to try one more practice problem from the Facebook web site. Balance Brackets is a very common problem. In general the idea is that you are given a set of brackets and are sked to determine if the brackets are balanced.

I knew I have solved similar versions of the problem. When done with the code I move to a different computer and type in the contents for the post. I looked up in my web site for the string “balanced brackets” and found Balanced Brackets and Balanced Brackets – Possible Second Attempt. I generated the post in 2016 and 2017 respectively. I guess, we will have a third version. Continue reading “Balance Brackets”

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”

Best Time to Buy and Sell Stock – Java

It is Sunday morning on a gloomy and cold day in fall in the Twin Cities of Minneapolis and St. Paul.

Last evening my wife and I watched Peppermint on Netflix. We both like most of the movies with Jennifer Garner. The ending of the movie could be somewhat debatable. In a nutshell, the husband and daughter in the movie are murdered by a drug dealer. They did not happen to be a casualty, they were all targeted. The core of the movie is based on what the surviving mother does to get justice for what happened. Towards the end of the movie she completes her tasks. Then the part that might be debatable is shown. I am not going to spoil the ending in case you are interested in watching the film.  My wife and I liked what transpired in the last couple minutes of the movie. Continue reading “Best Time to Buy and Sell Stock – Java”