In this post we will solve the LeetCode 229. Majority Element II problem using two approaches.
Given an integer array of size n, find all elements that appear more than floor(n/3)times.
o 1 <= nums.length <= 5 * 10^4
o -10^9 <= nums[i] <= 10^9
We are given an array of integer values. We need to find all elements whose values are larger than floor(n / 3), where `n` is the number of elements in the input array. Continue reading “LeetCode 229. Majority Element II in Java”
In this post we will not be solving a problem yet. This post is about code I wrote to experiment with differences between file and block storage.
In this post we will start by writing some data into individual files. This will set the ground for some differences that arise when you access similar data in block mode possibly in a cloud storage setting.
This code has been written in C on a Windows platform. For my benefit regarding ease of development, I have used some previous code found in a set of libraries which at this point I am not allowed to disclose. That said; when we encounter such calls I will suggest ways you can replace them with much simpler code. Sorry for the inconvenience this may cause. Continue reading “Block Storage vs. File Storage – Part 1”
I did not find this problem on a website. The requirements came up during a conversation with a software engineer. I wish I could have taken some notes but I did not. The problem had a single diagram of a sample general tree and there was no class definition for the nodes.
We are given a general binary three in which a node may have none, one or more children.
In addition each node has an integer value.
The values may repeat.
Our tasks if to come up with a function
that will display the leaf nodes
for which the sum of all node values in the path from the root
add up to a defined target.
As far as I can remember that was the gist of the problem. Continue reading “Find Leaf Nodes in a Tree for which the Sum of the Root Path Matches a Target Value”
Good morning. I received a comment from Dmytro regarding the post Slow Sum suggesting the use of a priority queue instead of a stream. I appreciate the comment and suggestion. Continue reading “Slow Sum – Revisited”
Good morning. Hope you enjoyed the Halloween festivities yesterday. Today is November 01, 2021 and most countries celebrate today “All Saints’ Day” and tomorrow “All Souls’ Day”. In the USA we do not celebrate these holidays.
One way or the other, yesterday shortly past noon the crew of technicians installing our new furnace left, leaving us with an installed, calibrated, and properly functioning furnace. Last night the low temperature in this part of the Twin Cities of Minneapolis and St. Paul was 30F. The furnace worked a few times at night. It was quieter than our previous unit. What is more important, it worked flawlessly.
Today I have a couple meetings. Besides that it will be a normal workday.
Continue reading “Two Sum II”
Good day. It is Wednesday and it feels like winter is just around the corner in the Twin Cities of Minneapolis and St. Paul.
Earlier today I attended an O’Reilly webinar. The subject was not as interesting as I thought. What called my attention was the fact that I had to download and install the RingCentral app. After the webinar was done I removed the app from my computer. For security reasons, I prefer to keep installed only the apps that I frequently use and download the ones that I seldom use when needed.
The app seems to be easy to use. I checked RingCentral on Wikipedia. The company is traded in NYSE and the company was founded in 1999. In 2019 their revenue was 902.8 million USD. Looks like the founders figured out there was an opportunity to profit during the COVID pandemic, and they offer a good product.
Out of curiosity, I looked up Zoom Video Communications on Wikipedia. I did not know that it was founded in 2011, long before the COVID pandemic. In 2021 their revenue was 2.7 billion USD. Zoom is another app that I install on my computer when needed.
Over the weekend visiting my younger son, the subject of personality types came up. My daughter in law sent me a few links. I have been reading them on and off. Will have more to say about my findings in my next post. Continue reading “Search Insert Position”
Good day! It is another sunny Monday in the Twin Cities of Minneapolis and St. Paul. Had a rather busy weekend. My wife and I visited our youngest son who lives in Madison, WI. Drove last Friday afternoon and returned yesterday. The drive is about 3 ½ hours each way. Traffic was fine in both directions. This time of the year is nice because it is cold enough that bugs do not hit the windshield and warm enough that there are no slippery ice spots on the roads.
It is nice to visit family. My wife and I try to connect with our booth sons every day for a few minutes. We use FaceTime, Jitsi and occasionally just the phone. That said; nothing beats in person visits. I agree that with the COVID pandemic we have gotten used to converse on-line, but technology has ways to go in order to match in person communications.
Last Friday, I woke up around 03:00 AM and noticed that the furnace was running but the incoming air was not warm enough. After some investigation I was able to determine that the furnace was not heating. I assumed that the pilot might be off. I would rather not deal with it, so my wife called for service. They told her that due to the cold weather on Friday they were booked. Since the temperature was not going to dip during the next week or so, it would make sense to have a technician stop by on Monday (that is today). We have an appointment between noon and 03:00 PM CDT. In addition, we would not have to delay our departure on Friday and we will be back late on Sunday.
On our return home, the inside temperature was around 64F. I started the living room fireplace and the ceiling fan. When we were ready to go to sleep, the upstairs temperature was at 72F. Perfect for sleeping on a fall night. Clicked on the remote and the fireplace turned off. The built-in fan continues to circulate air for about 2o-25 minutes after being shut down.
This morning I woke up around 05:30 AM and turned on the upstairs fireplace and the ceiling fan. After breakfast I shut it down and turned on the lower level fireplace and ceiling fan. My office is downstairs. After showering and getting dressed I went down to a nice and toasty office. I decided to turn off the fireplace. Continue reading “Binary Search Iterative”
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”
Good day software engineers and developers! It is a Thursday morning and seems like it will be a sunny day with highs in the low 70’s F. Like I mentioned in a previous post, the days are getting shorter and cooler. My wife and I decided to walk after the workday is over. We tried it yesterday and by 06:00 PM we were back home. At that time there is daylight and the temperature is much higher than earlier in the day. Continue reading “Minimum Loss”
Hope you are having a wonderful day! The temperature in the Twin Cities of Minneapolis and St. Paul continues to be way above normal. Today is going to be another spring day with temperatures in the upper 90Fs. My wife and I continue to walk after breakfast. The days are sunny so it is very nice to get our daily walk out of the way early.
Yesterday we had a short thunderstorm with heavy rain. The rain lasted about 30 minutes. It was good for the plants. Tomorrow we also expect some rain.
Something that we have noted in the past couple weeks is that there are more insects. We had to swat a couple flies and a couple bugs in our place. We can also see a few of mosquitoes and wasps. I guess that is to be expected when the weather gets warmer than average. Hope all is going well with farmers. Their crops feed livestock and us. This weekend my wife and I will go to a couple Farmers Markets. On Saturday we will stop by the one in Apple Valley and on Sunday the one in St. Paul. Will let you know our findings next week. Continue reading “Can Sum – Tabulation”