Divide Chocolate

Good day! Hope your workday has started on the right note. Currently in the USA we are observing the Daylight saving time which this year ends on Sunday, November 7, 2021. Today is Thursday October 14, 2021 so we have a little over one month for the time to get back to normal.

I see the positive sides of daylight savings time during summer. In my opinion, in the USA, daylight savings should start on Memorial Day and end on Labor Day. The reason for this is that schools and universities tend to be off during such period.

For college students it should not make much of a difference, but for K-12 students it does. Most children use public school buses to commute to school. Depending on the grade they attend, they may be picked up in the morning around 07:00 AM. I am always up before 06:00 AM. I am a morning person. After fixing breakfast I wake up my wife so we can have the first meal of the day together.

After we are done with breakfast, she helps me with the dishes. After rinsing the dishes and putting them in the dishwasher I shower, get dressed, and head down to my office to work on my first 2-hour block of the day. This includes weekends in which I work one or at most two blocks. On regular workdays I tend to do four to five blocks a day.

For the past week or two, when I head down to my office, the day is very dark, to the point that I have to turn on lights. It happens that when I am heading down is about 07:00 AM and I see kids that are already riding public school busses. They had to walk from home to the bus stop while it is quite dark. I thought that children were first in our society. It seems I am wrong. Go figure!

In the month that we have to wait before daylight savings ends, it will be dark close to 08:00 AM. So why is this happening? Well, the thought is that if the school day ends with some light, parents will be more prone to head out and grab a bite which is good for business. I guess children do not have much homework in these days. Things have changed since I attended K-12. Continue reading “Divide Chocolate”

Binary Tree Upside Down

Today is Sunday. As usual I woke up at 06:00 AM and it was dark. I decided to stay in bed for a few minutes before getting up and fixing breakfast for my wife and me. The next thing was waking up around 06:45 AM. The day was clearing some, but still dark enough to require artificial light. I understand that if you fall asleep after your alarm clock goes off, that it is an indication from your body that you need additional sleep. That said; I do not recall doing much yesterday. Go figure!

As usual, for breakfast I make espresso on our Bialetti 6-cup Moka pot. Growing up my parents owned several Moka pots of different capacities. Some were used on a daily basis and others when my parents entertained family and friends. With time my mother started using a drip pot. She liked to get the first few drops and add some hot water. It was almost impossible to drink it straight up. Continue reading “Binary Tree Upside Down”

Tower of Hanoi

My end of the working day is coming to an end. Tomorrow is Friday! It has been a long week.

This week I spent some time refreshing and learning more about recursion. One of the problems is named Tower of Hanoi. Long time ago I received as a present a wooden board with three pegs and ten discs. If you check the link I just mentioned, on the top right corner in the Wikipedia article you can see a very similar board to play the game.

You can use the following article Program for Tower of Hanoi as inspiration on how to solve the problem.

Continue reading “Tower of Hanoi”

Flatten a Multilevel Doubly Linked List

Good morning software developers and software engineers! Hope your day has started on the right note. Every morning, weather allowing for it, my wife and I have breakfast and go for a brisk walk. Today was no exception. Before 08:00 AM I have watered plants in the yard including a rosemary bush that we planted a week ago or so, showered, shaved, got dressed and started my work day. It is amazing how well you feed during the day once you have exercised, no matter how short or long.

Last week I read the article (let me see if I can find it in my Twitter account @john_canessa … found it) Cybersecurity bills gain new urgency after rash of attacks. It seems that both political parties, Democrats and Republicans are pushing a bill that will help our country against cyber attacks. In the past few months we have seen hundreds if not thousands of attacks, some to disable our government, companies and organizations or to ask for ransom. One of the proposed ideas is to force targets to disclose in a short period of time (24 hours or so) any cyber breach they have experienced. This will allow the government and other organizations to take action as needed to prevent the same type of attacks. In my opinion there should be some type of penalty for the bad actors in an attempt to curb their proliferation (transparency and accountability). Will see what happens with the bill and its implementation! Continue reading “Flatten a Multilevel Doubly Linked List”

Unique Binary Search Trees

It has been raining all day in the Twin Cities of Minneapolis and St. Paul. The good thing is that there has been little lightning. I was going to replace an old UPS that I am using to power my main computer in which I develop all the code for this blog, but it was not necessary. I will replace the UPS over the weekend. Continue reading “Unique Binary Search Trees”

Count Sub Islands

It is Thursday July 01, 2021 in the Twin Cities of Minneapolis and St. Paul. The forecast called for a sunny day but clouds have rolled in and out. Hopefully it will not rain.

After having breakfast, my wife and I went out on our daily walk. We run into several people we know. Perhaps people want to get in their workout before heading out for the long weekend. The fourth of July falls this Sunday, so the observed Independence Day (United States) is Monday July 05, 2021.

We do not have plans for the holiday. We will stick to our daily routine. I will try to get in one or two work-blocks each day in addition to do groceries and visit the Farmers Market in St. Paul. For one reason or another this year we have not shopped there yet. Continue reading “Count Sub Islands”

Generate Parentheses

For lunch my wife made a pork and cauliflower dish. She added a few drops of Green Dragon Hot Sauce. It goes very well with pork dishes. For desert we had gypsy arm filled in with dulce de leche with strawberries on the side. Lunch was quite good. After chatting for a few and doing the dishes and pots I got back to my home office. Continue reading “Generate Parentheses”

Symmetric Tree

Good morning gals and guys! Hope you day has started on the right note. Today in the Twin Cities of Minneapolis and St. Paul we are expecting a high temperature of 67F and the day is sunny. Starting today the two-week forecast shows high temperatures in the upper 60’s to mid to lower 70’s. All looks nice, but we are somewhat low on precipitation. From my backyard I can see a small pond with very low water levels. Hopefully farmers are receiving enough rain to have a good crop this fall.

This morning I watched a session from AWS Summit Online. The session is named “Amazon DynamoDB: Untold stories of databases in a serverless world” by Angela Timofte. She is a data platform manager with Trustpilot. What called my attention were a set of points she brought up which illustrates how important is to allow your technical staff to experiment, learn and make mistakes. Such approach has helped the company move from MySQL to MongoDB and currently to DynamoDB. What is more important, the company currently uses about ten different database engines to store different types of data. They are using the right tools for the jobs (one size does not fit all). If you get a chance take a look at the 22 minute presentation here. Continue reading “Symmetric Tree”

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”

All Elements in Two Binary Search Trees

The temperature in the Twin Cities of Minneapolis and St. Paul continues to oscillate between negative and positive values in the Fahrenheit scale. The good thing is that we are around mid February. This year spring starts Saturday March 20. That is about 6 to 7 weeks from today. Continue reading “All Elements in Two Binary Search Trees”