Fibonacci Revisited using GitHub Copilot

It is Saturday morning in the Twin CIties of Minneapolis and St. Paul. The forecast calls for a rainy weekend. My wife and I were hosting two of her brothers and spouses for lunch, but one of the couples, due to health issues, decided to cancel. My wife and I like to cook and have made food for more than three couples. We should have leftovers for a day or two.

Last week we were out of town in Houston, Texas visiting family. We had to run a family errand. We took care of it. My wife has many relatives that live in that area. It was fun visiting them, walking by lakes, parks, and having very good food in so many local restaurants. We included a Texas style BBQ hole in the wall. Probably the best brisket and beef ribs that I ever had. Continue reading “Fibonacci Revisited using GitHub Copilot”

DOP Underscore

If you tried accessing my post last week you were not able to do so. Sorry about that. I use WordPress and apparently it had a problem with the JetPack plugin. I started using WordPress on a different blog about a decade ago. Since then I have changed my main computer three times. It seems that each time you get a new computer some stuff is left behind. In my case I lost some connection information which prevented me from accessing the site hosting the WordPress blog and addressing it.

That said; it seems that when an issue is detected in a WordPress site that prevents a blog from functioning, the admin receives a daily message with instructions to help mitigate the problem. With the help of my son who was kind enough to retrieve credentials for this blog, I was able to mitigate the issue and get the blog up and running. Sorry about the inconvenience. Continue reading “DOP Underscore”

First ChatGPT Post – Populate Binary Tree

Hope your weekend is going well. I will start with an unrelated event to the main subject of this post.

When I was working at my first job in Minneapolis, Minnesota the Red Cross would stop by at work for blood drives. They made it simple, so I started to give blood once a year.

Time went by and I decided to do it twice a year (one for my wife and one for me). I had my first appointment for 2023 last Friday afternoon. All went well as usual up to the point in which after the gauze was taped to my arm to protect the area from which the needle was removed. The technician offered a bandage to put pressure over the gauze to protect it for a couple hours. I have always declined and this time was no different. Continue reading “First ChatGPT Post – Populate Binary Tree”

Longest Absolute File Path – C# and Java – Revisited

Hope you had a nice Thanksgiving day with family and friends. My wife and I typically roast a turkey. This year, for the first time, we went with a fresh turkey breast. It was a fraction of the weight of a full turkey and when all was said and done, my wife did not have to deal with cleaning the bones. Today, and probably for the next few days, we will be having different types of turkey sandwiches (Bread, butter on the outside, panini press @ 350F, turkey meat. When brown and crunchy, open sandwich, apply mayonnaise and a touch of mustard. Close and enjoy).

In this post I will revisit solving LeetCode 388. Longest Absolute File Path. The motivation was a message I received a few days back on a solution in O(n). I looked up my solution in Java from February 27, 2017 and it was hard to follow. At the time I used a different plugin and the output was not that great. With time it stopped working so I switched to a different one. Much better but sometimes it mangles the output. Continue reading “Longest Absolute File Path – C# and Java – Revisited”

Interval HashMap

A couple weeks ago, during a meeting, someone mentioned an interval hashmap. I decided to check if Java had a class implementing a version of an interval hashmap. As you can imagine, it does and is called NavigableMap.

In this post I explored some of the features available in the NavigableMap interface.

If interested, I would suggest to first take a look at the Interface NavigableMap<K, V> in the Oracle Java documentation which can be found here.

After reading the Oracle documentation and some articles in GeeksforGeeks and StackOverflow I decided to start experimenting. Continue reading “Interval HashMap”

Rabin-Karp Algorithm – Revisited

In this post we will revisit the implementation of a string-search algorithm developed by Richard Karp and Michael Rabin.

We visited this algorithm in this blog a few years ago. My motivation is a book that I am currently reading. As soon as I am done reading and experimenting with some more advanced algorithms, I will generate several posts associated with the book.

In the meantime, let’s refresh what the Rabin-Karp algorithm is used for and go over an implementation using the Java programming language. Continue reading “Rabin-Karp Algorithm – Revisited”

Bubble Sort in Java

It has been a few weeks since my last post. I apologize for this. Will let you know after my current quest is completed. Hopefully everything will turn out as I desire.

In the meantime I have been taking a few on-line courses.

I am almost done with the course C++20 Fundamentals by Paul J. Deitel. The course was released July, 2021 and published by Pearson3. The ISBN: 013687518. This online course is made available through O’Reilly. I am a member of the Association of Computing Machinery and have access to several O’Reilly titles. Continue reading “Bubble Sort in Java”

Largest Triple Product Third Post in Java

In this post we will revisit a practice question Largest Triple Products. Not sure if today this question would be of interest to Facebook and /or to Meta Platforms technical job seekers.

My original post Largest Triple Products was superseded by Largest Triple Products – Revisited and by this latest post.

The motivation for this post came from a question left by Brent Boyer which suggested an implementation for the function of interest. I have included it in this post as `findMaxProduct3`. Continue reading “Largest Triple Product Third Post in Java”

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
* Breadth-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 295. Find Median from Data Stream in Java

In this post we will try to solve the LeetCode 295. Find Median from Data Stream problem using the Java programming language and the VSCode IDE on a Windows computer.

The median is the middle value in an ordered integer list. 
If the size of the list is even, 
there is no middle value and the median is the mean of the two middle values.

For example, for arr = [2,3,4], the median is 3.
For example, for arr = [2,3], the median is (2 + 3) / 2 = 2.5.

Implement the MedianFinder class:

o MedianFinder()
	initializes the MedianFinder object.
o void addNum(int num)
	adds the integer num from the data stream to the data structure.
o double findMedian()
	returns the median of all elements so far. 
	Answers within 10-5 of the actual answer will be accepted.
	
Constraints:

o -10^5 &lt;= num &lt;= 10^5
o There will be at least one element in the data structure before calling findMedian.
o At most 5 * 10^4 calls will be made to addNum and findMedian.

Related Topics:

o Two Pointers
o Design
o Sorting
* Heap (Priority Queue)
o Data Stream

In a nutshell the class needs to process integers in the specified range and at different points we can be asked to return the current Median. As a brute force approach, I tried sorting. I did not submit such an approach because it is quite expensive (slow) and the problem is rated Hard by LeetCode. Continue reading “LeetCode 295. Find Median from Data Stream in Java”