Notes from the UnsafeCSharp Presentation

At work each month a set of hours are set aside/scheduled for employees to learn something new. I have worked at more than a dozen companies and have never seen a periodic time scheduled in the company calendar for it. Yesterday we had eight hours scheduled for learning. During that time an invite for a one hour presentation UnsafeCSharp showed up. I watched and enjoyed it. In addition most presentations at work are recorded so I am planning on watching it again later today.

As I am writing this post I am not sure if there are things that were presented that are company confidential. For that reason, at this time I am not disclosing the name of the presenter or will dive into specific topics. Continue reading “Notes from the UnsafeCSharp Presentation”

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”

LeetCode 75. Sort Colors in Java

In this post we will solve the LeetCode 75. Sort Colors problem using the Java programming language and the VSCode IDE on a Windows computer.

Given an array nums with n objects colored red, white, or blue, 
sort them in-place so that objects of the same color are adjacent, 
with the colors in the order red, white, and blue.

We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.

You must solve this problem without using the library's sort function.

Constraints:

o n == nums.length
o 1 <= n <= 300
o nums[i] is 0, 1, or 2.

We are given an integer array with values 0, 1, and 2 which represent colors red, white and blue respectively. We must solve the problem without the use of any library sort function. That makes sense because we would only have to sort the input array and return. Continue reading “LeetCode 75. Sort Colors in Java”

Reverse Words in a String III

Good day! Hope your day has started on the right note. Earlier today I participated in a video call using Zoom. I have avoided using Zoom due to security issues. Today I had to install it in order to participate in the call. It seems that the look and feel has improved considerably. Will read more about security issues in the past few months. One way or the other, after the call ended, I removed the application from my Windows computer.

I was chatting with a software engineer and the idea of replacing the garbage collector in Java came up. In general you would replace it if it is not keeping up with the task (i.e., too many requests when processing IoT calls). I am aware and have done it using C and C++. After completing this post I will spend an hour researching more on this subject. Continue reading “Reverse Words in a String III”

Move Zeroes

It is Sunday October 31, 2021 and you are correct, it is Halloween. Woke up as usual just before 06:00 AM. The temperature outside was 39F and the inside temperature was 66F. It all started nine days ago when I noticed that the furnace was not generating heat. This morning the second company that my wife and I selected for the job showed up with a brand new furnace. The two technicians in a pickup truck towing a closed trailer set sheets on the floor in the lower level from the door to the utility room.

In less than a couple hours the furnace was removed and loaded in the trailer. When they were hailing in the new furnace, two more technicians showed up to help. It seems that the job will be done in about four hours. I was impressed with the quality of job, courtesy and attention to detail.

If you live in the Twin Cities of Minneapolis and St. Paul area and have an issue with your furnace of AC units, leave me a message and I will pass on the name of the company.

As I am getting ready to publish this post the furnace crew is finishing testing the installation of the furnace and is starting to put the furniture back in place. I was expecting that the job would take about six hours, but due to the additional number of technicians the job should be completed in less than five hours!!! Continue reading “Move Zeroes”

Best Time to Buy and Sell Stock II

It is a relatively nice day in the Twin Cities of Minneapolis and St. Paul.

This weekend my wife and I will go to visit our younger son. His house is about three hours by car. It does not make sense to fly. It will take longer than driving when you consider the overhead at the airports.

I continue giving it a try to the process to solve dynamic problems using some simple steps as described in the paper Dynamic programming is simple by omgitspavel. Each time I give it a try I add additional guidance.

The main problem that I see with the approach is that one still has to read, understand and explore other methods before diving into dynamic programming. The problem we will be solving in this post can be resolved faster and better not using dynamic programming. Continue reading “Best Time to Buy and Sell Stock II”

Best Time to Buy and Sell Stock with Transaction Fee

Good morning! Hope you had a great weekend. The weekend was not too exiting for my wife and me. We did replenish our freezers for the next few months. I believe we have enough supplies to last us through a good part of spring 2022.

We decided to cook some ribs in the oven. We have done this several times, but due to the fact that my wife is not too fond of such delicacy we have not cooked them in about three years. I pulled the ribs from one of the freezers and put it in a refrigerator for three days. On Friday evening I took them out of the fridge and they were still partly frozen.

On Saturday morning after breakfast I rubbed some salt and pepper on the ribs. Like I mentioned, she is not too fond of ribs or BBQ sauce. I wanted to add some that we got at Trader Joe’s a couple weeks ago. I ended using the sauce on my dish. My wife used an Asian sauce which went very well with ribs. We also bought that sauce at Trader Joe’s.

I was going to set the oven at no more than 300F, but my wife suggested 325F to get them done faster. The ribs went in around 07:00 AM. After showering and getting dressed, I went down to my office for a 2-hour block.

Later that morning my wife and I sat down for a cup of triple espresso. We chatted and decided to get a couple items at a specialty grocery store in St. Paul. We turned off the oven and headed out. In retrospect, we should have removed the ribs from the oven. We had lunch around 01:00 PM and the ribs got a little dry for my taste. We had them with brown rice and black beans. We both enjoyed them, but once a year is enough. The taste is very unique like turkey. We have turkey on Thanksgiving Day and perhaps Christmas. I guess most people do the same in this part of the country.

On a separate note, I ran into the article Was Our Universe Created in a Laboratory? by Avi Loeb published on Scientific American on October 15, 2021. The article starts with the word “Opinion” which puts it into perspective.

I am not going to get into the implications of the ideas in the article. My parents taught me never to discuss religion, money or sex. Such subjects are very opinionated and it is hard to get a general consensus. That said; here we are talking about the article. The reason for me to bring it up is due to the fact that for the past three decades or more, when my wife and I talk in private, I have described to her the idea of multiple universes generated by beings more advanced than us. In such universes there are some actual beings and many artifacts. The idea behind is to study scenarios that in general fall outside our comprehension and interests.

I have to tell you that as soon as I read the article, I ran to my wife to tell her about it. We both thought it was very interesting.

In my thoughts and opinion, the article does not exclude a superior being that is above all levels. It just puts such being above the more advanced civilization(s) that at this point are able to generate universes.

I will try to contact the author of the article and let him know that I really enjoyed reading it. After an hour or so of sending my message to the author, I received a reply. Thanks. Continue reading “Best Time to Buy and Sell Stock with Transaction Fee”

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”

Find N Unique Integers Sum up to Zero

The weather is slowly changing in the Twin Cities of Minneapolis and St. Paul. Days are getting shorter and the temperature is going down. Winter appears to be around the corner. That said; the vegetation in the area is not as dry as other years. Hopefully we will have a not so cold winter.

In addition, today is October 12th, the actual day that Christopher Columbus discovered America. The day was celebrated yesterday in the USA. Note that Christopher Columbus landed in what is today Central America and went south. He did not put a foot on North America.

I continue watching and experimenting with the contents of the on-line course on Python. I am currently in Lesson 4. In addition I am reading the associated book “Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud 1st Edition” by Paul Deitel and Harvey Deitel. Continue reading “Find N Unique Integers Sum up to Zero”