## Fibonacci Numbers in C++

In this post we will write a couple functions to generate Fibonacci Numbers using the C++ programming language and the Visual Studio 2022 IDE, on a Windows 11 computer.

The motivation came from the on-line course C++20 Fundamentals by Paul J. Deitel, included in the O’Reilly Learning Platform offered by the Association for Computing Machinery.

```C++20 for Programmers
by Paul Deitel and Harvey Deitel
Format:	        Paperback
Language:	    English
ISBN:	        0136905692
ISBN13:	        9780136905691
Release Date:	March 2022
Publisher:	    Pearson Education
Length:	        1008 Pages
```

I have preordered the new book associated with the course on Amazon. Hopefully it should arrive next month. Continue reading “Fibonacci Numbers in C++”

## LeetCode 111. Minimum Depth of Binary Tree in Java

In this post we will solve LeetCode 111. Minimum Depth of Binary Tree problem using Java and the VSCode IDE on a Windows computer. Not that it matters, but I am using Windows 11.

```Given a binary tree, find its minimum depth.

The minimum depth is the number of nodes along the shortest path
from the root node down to the nearest leaf node.

Note: A leaf is a node with no children.

Constraints:

o The number of nodes in the tree is in the range [0, 10^5].
o -1000 <= Node.val <= 1000

Related Topics:

o Tree
* Depth-First Search
o Binary Tree
```

We are given the root of a binary tree and are asked to find the minimum depth of the tree. A couple years ago we solved in this post Maximum Depth of a Binary Tree.

The definition of minimum depth is provided in the requirements for the problem at hand. Continue reading “LeetCode 111. Minimum Depth of Binary Tree in Java”

## LeetCode 79 Word Search in Java

In this post we will tackle the LeetCode 79 Word Search problem using the Java programming language.

```Given an m x n grid of characters board and a string word,
return true if word exists in the grid.

The word can be constructed from letters of sequentially adjacent cells,
where adjacent cells are horizontally or vertically neighboring.
The same letter cell may not be used more than once.

Constraints:

o m == board.length
o n = board[i].length
o 1 <= m, n <= 6
o 1 <= word.length <= 15
o board and word consists of only `lowercase` and `uppercase` English letters.

Related Topics:

o Array
o Backtracking
o Matrix
```

We are given a grid (or two dimensional array) of characters and a string `word`. Our task is to determine if we can find the specified `word` in the matrix following the specified rules. Continue reading “LeetCode 79 Word Search in Java”

## 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.

## 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”