Producer and Consumer

Hope you are doing well. I fully understand that not all countries are moving quickly to vaccinate most their population against COVID-19. Hopefully the efforts have already started and will be completed soon. Here in the USA it seems that every state is moving at its own pace. That said, a large amount of people have received at least the first of two jabs. The youngest I know of is of age 21. The world needs to get as much of its population vaccinated as possible to achieve herd immunity. If this is not done the virus will continue to mutate and the threat of COVID-19 might remain for years or decades.

It seems that Israel is leading the vaccination process. As in many other countries, there are some people that do not wish to get vaccinated. The prime minister of Israel has made some clever, and for what I understand legal changes to motivate all their citizens and residents to get a COVID-19 vaccine.

In a nutshell the idea is that the good of the majority needs to prevail. People will not be forced to get a vaccine unless there are medical reasons. Besides that, the population needs to show a vaccine passport to work where there is human contact with others. If the person wishes to attend events and places where they could possibly transmit COVID-19, they need to have a COVID test in the previous 48 hours. The COVID tests used to be free but in the near future people will need to pay for a test. So if a person for without a real medical issue does to get the vaccine but wishes to mix and mingle with others, they will have to pay and get a COVID test every other day. I guess Israel will be one of the countries that will reach heard immunity in the very near future. In my humble opinion, we in the USA need to start thinking about each other and work for a common goal. Continue reading “Producer and Consumer”

Maximum Score of a Good Subarray

Good morning. Hope your day has started on the right note. If you follow this blog you have noticed that I recommend social distancing in order to reduce the chances of COVID-19 to spread in your local community. My wife and I wear a mask when we go shopping. As soon as we return to our vehicle we remove the mask and apply had sanitizer to our hands. We are planning to continue this behavior for the foreseeable future.

My wife has been to the Mall of America a couple times during the pandemic. She and a friend have not been shopping but walking. On each occasion my wife told me that the mall was almost empty with many stores closed. That is a shame. Continue reading “Maximum Score of a Good Subarray”

Clone Graph in Java

It is Friday morning and I am getting on Skype to chat with my best friend. We met when we were attending elementary school. We chat most Fridays but sometimes something comes up and we need to postpone for the following week. All friendships need care and time to maintain. The call occurs at 06:00 AM so hopefully I will have time to get this post done before the call.

The weekend is going to be the warmest of the year so far. We will be around 60F. Most people are going to use their grills or smokers. I believe we will join the group.

I received a message associated with a previous post. I will reply to it later today. The message suggests some improvements to my code. First of all I appreciate the message and suggestion. Please note that in general I want to get a solution up and running and accepted by the web site (e.g., HackerRank, LeetCode). If the solution is too slow, in general I try a second and in some occasions a third approach. I am not going to say that I have the best possible solution. I just want to make sure I describe my approach and you can see my thought process. Continue reading “Clone Graph in Java”

Union Find Java

It is Monday morning. Lots of work associated things for the day so this post will be direct to the point.

As I have previously mentioned, I am in the process of reading Algorithms in C Third Edition Parts 1 – 4 by Robert Sedgewick. I finished the first chapter and wanted to experiment with the content in the book. Yesterday I got VSCode on my machine to compile and execute. I thought I was ready to use the IDE in C. It seems that when I created a new project something did not work. I am currently using the MinGW compiler with VSCode. The issue might be associated with it. I decided that over the next weekend I will remove MinGW and will switch to the Microsoft C/C++ compiler. I do a considerable amount of work using Visual Studio Enterprise 2019 IDE. Have been using Visual Studio for a couple decades and I like it. VSCode is quite similar but yet different. Continue reading “Union Find Java”

Setting Up C in VSCode IDE

It is another Sunday morning in the Twin Cities of Minneapolis and St. Paul. The weather forecast indicated that we would be receiving about 3 inches of fresh snow. It seems that we will be getting about 0.1 inches of new accumulation. Given that today is February 28, in the next couple months we might still get winter storms bringing 6 or more inches each.

This past week I had a very nice and interesting conversation with a Principal Software Architect at one of the largest software companies in the world. It was very educational. I really enjoyed the conversation. One of the things that initially called my attention was when I asked the kind of things he does on a regular basis. He mentioned that he “provides guardrails” among other things. When he mentioned it I was not sure what he meant so I made a note to ask him later. At some point I had a chance to describe what I do and have done. One of the things I mentioned was sets of DLLs that with time I have created with the purpose to help developers use a set of tools to get some routine work done without having to redesign and test code use as a scaffold and be able to concentrate on the task at hand. Among the libraries that I have developed are some that deals with encryption, linked lists (I refer to them as queues), sockets, trees, etc. I was then clarified what “guardrails” refer to. It is the same concept in order help developers produce faster code with fewer bugs. It seems that we are performing some similar tasks. Continue reading “Setting Up C in VSCode IDE”

Binary Tree Maximum Path

It is a Saturday morning in what has been forecasted so far as the coldest weekend of this winter season in the Twin Cities of Minneapolis and St. Paul. I woke up this morning around 05:00 AM and the temperature was at -8F. It seems like it will go up a few degrees during the day until it starts dropping down in the mid afternoon. On Sunday we should we waking up to a balmy -20F. My wife and I did our grocery shopping for the week yesterday evening. We are not planning on leaving home this weekend.

Earlier today I read Cybersecurity: Is it Worse than We Think? authored by Chris Maurer, Kevin Kim, Dan J Kim, and Leon Allan Kappelman in the latest Communications of the ACM magazine. The article is interesting, but there was a sentence that called my attention the most. The sentence follows:

“While they [organizations] may be saying the right things in public to satisfy investors, underwriters, and customers, there is an apparent lack of urgency in promoting a truly resilient and secure organization”.

You need to read the article to fully understand the meaning. In my opinion addressing cyber threats requires an investment which has no obvious ROI. Given that the word on the street is that it is not if but when a company will be hacked, then by doing as little as possible and carrying insurance to cover the cost of a breach seems the best approach. Of course if you ask a customer whose PID has been published in the dark web, the sentiments might be quite different. Continue reading “Binary Tree Maximum Path”

Binary Tree Pruning

Have an on-line call at 02:30 PM. I believe I am well prepared. Will see how it goes.

Earlier today I selected LeetCode 814 Binary Tree Pruning problem.

We are given the head node root of a binary tree, 
where additionally every node's value is either a 0 or a 1.

Return the same tree where every subtree (of the given tree) 
not containing a 1 has been removed.

(Recall that the subtree of a node X is X, plus every node that is a descendant of X.)

Note:

o The binary tree will have at most 200 nodes.
o The value of each node will only be 0 or 1.

We are given a binary tree whose nodes are holding 0 or 1 as value. We need to prune the BT as described in the requirements. If you are interested in this problem please navigate to the LeetCode web site and read the actual requirements. In addition LeetCode has a set of test cases.

In this post we will solve the problem using the Java programming language on a Windows 10 computer using the VSCode IDE. You can use any of the languages supported by LeetCode and solve the problem on the LeetCode side with the IDE provided. Continue reading “Binary Tree Pruning”

Sort the Matrix Diagonally in Java

Good morning. It is Sunday again. I woke up around 05:00 AM and the outside temperature was -17 F. We are finally experiencing cold winter days in the Twin Cities of Minneapolis and St. Paul. An added bonus for football fans is that today is Super Bowl LV. My wife and I are not sports fans. We like to bike and walk and occasionally scuba dive. Up to a couple years ago we would watch the half time show. We so not watch TV any more. Perhaps we will find the half time show on YouTube. Continue reading “Sort the Matrix Diagonally in Java”

Shuffle an Array in Java

I have mentioned in recent posts that this year the temperature in the Twin Cities of Minneapolis and St. Paul has not dropped down to 0F yet. Well, that is changing this Sunday. It seems that the high temperature for the day will be -6F and the low -20F. The good news is that according to the forecast, the temperature will increase rapidly in the following days.

Last weekend I spend several hours on work stuff. Hopefully the following weekend will be a normal one. Not sure if my wife and I will be venturing out on the forecasted cold. Continue reading “Shuffle an Array in Java”

Encode and Decode TinyURL in Java

It is Sunday morning again. It seems that time is flying by faster than ever. Yesterday I worked all morning (about 6 hours). My daughter in law was going to visit her family and my son had to stay home. They were expecting a delivery and installation of a piece of exercising equipment. The delivery was scheduled between 03:00 PM and 06:00 PM.

Earlier that day I had made some pizza dough. I used to knit the dough by hand. In the past couple years I have switched to using our Kitchenaid mixer. I can take all the ingredients, mix them and put the dough to rise in about 25 minutes. I do it while chatting with my wife during breakfast. She just watches me switch tasks while having yogurt with homemade granola and warm milk with a triple espresso. We both like to drink coffee. Continue reading “Encode and Decode TinyURL in Java”