It is Wednesday morning and the cleaning crew is at our place making lots of noise. Typically they show up on Fridays but due to personal issues they requested to move the appointment. They do an excellent job. If you live in the Twin Cities of Minneapolis and St. Paul and are in need of a good cleaning service, please let me know. I will pass your information so you can get in touch with them or vice versa. I value privacy. Continue reading “Implement Trie (Prefix Tree)”
Month: February 2021
Print Words Vertically
It is shortly after 05:00 AM in the Twin Cities of Minneapolis and St. Paul. The temperature is just under 32F. It should go up a few degrees as the day progresses. In reality I am at 68F in my office and not planning on leaving the house today.
I mentioned in a previous post that I had ordered from Amazon three books which would be delivered today Tuesday. The first arrived last Sunday, the second arrived yesterday Monday and just before going to bed I noticed a message from Amazon indicating that I should reorder the third book from a different reseller. One of the books was delivered at my home the second must have been dropped in my mailbox. Will check it at lunch time (after what I said, I guess I will leave the house for a few minutes), and I believe I have to look for the third book again. Continue reading “Print Words Vertically”
Best Time to Buy and Sell Stock – Revisited
It is once again Sunday. Time seems to keep passing on faster. I assume this has to do with the COVID-19 pandemic. Since most of us are limiting our social activities, the days and weeks seem to be much of a replay. The good news is that people are starting to get vaccinated and spring is just around the corner.
After chatting with a software development manager I decided to revisit LeetCode 121. Best Time to Buy and Sell Stock which is ranked as Easy by LeetCode. Continue reading “Best Time to Buy and Sell Stock – Revisited”
Design Linked List
It is Friday evening. It seems that the weeks are going by faster than ever. Hopefully the COVID-19 vaccine will make a huge difference all over the world and we will be able to get on with our lives.
Earlier this week, I decided to add some spice to this blog. If you are a follower you should have noticed that lately most of the problems are being solved in Java. In the near future I will be using C and C++ if such languages would provide simpler and higher performance solutions. That said, if I get a request to generate a solution in Java, I will generate a separate post. Continue reading “Design Linked List”
Making a Larger Island – Java
Hello everybody. I have been very busy looking into a problem at work which seemed to be caused by sockets. It seems that the issue might be related to encryption. Have a couple tests that should verify my assumption. Will let you know if that pan out.
Today in the Twin Cities of Minneapolis and St. Paul we woke up with a temperature above 0F (7F). Looking at the weather forecast it seems like the sub zero temperatures will be a thing of the past in a day or so. Weather forecasts are based on models and models in general are far from perfect, but they provide us with an idea of what might happen in the specified future. Continue reading “Making a Larger Island – Java”
Binary Tree Maximum Path
It is a Saturday morning in what has been forecasted so far as the coldest weekend of this winter season in the Twin Cities of Minneapolis and St. Paul. I woke up this morning around 05:00 AM and the temperature was at -8F. It seems like it will go up a few degrees during the day until it starts dropping down in the mid afternoon. On Sunday we should we waking up to a balmy -20F. My wife and I did our grocery shopping for the week yesterday evening. We are not planning on leaving home this weekend.
Earlier today I read Cybersecurity: Is it Worse than We Think? authored by Chris Maurer, Kevin Kim, Dan J Kim, and Leon Allan Kappelman in the latest Communications of the ACM magazine. The article is interesting, but there was a sentence that called my attention the most. The sentence follows:
“While they [organizations] may be saying the right things in public to satisfy investors, underwriters, and customers, there is an apparent lack of urgency in promoting a truly resilient and secure organization”.
You need to read the article to fully understand the meaning. In my opinion addressing cyber threats requires an investment which has no obvious ROI. Given that the word on the street is that it is not if but when a company will be hacked, then by doing as little as possible and carrying insurance to cover the cost of a breach seems the best approach. Of course if you ask a customer whose PID has been published in the dark web, the sentiments might be quite different. Continue reading “Binary Tree Maximum Path”
Flatten a Linked List in Java
This morning I read the article Kode Vicious Kabin Fever on Viewpoints in the latest copy of the Communications magazine from the ACM. I enjoyed reading the article. All of the points with the only exception to exercise, due to winter and the COVID-19 pandemic, with very few additions, are what I have been doing for over a decade. If you have time and are able to access the article, it contains good advice and it can be read in a few minutes.
Most problems in this blog come from companies such as HackerRank or LeetCode just to mention a few. In this case, the problem came up while chatting with a software engineer. I have developed the requirements as accurate as I can recall. I will be using the Java programming language on a Windows 10 machine using the VSCode IDE. Of course you can generate a solution in a different platform using a different IDE. Continue reading “Flatten a Linked List in Java”
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”
Sort the Matrix Diagonally in Java
Good morning. It is Sunday again. I woke up around 05:00 AM and the outside temperature was -17 F. We are finally experiencing cold winter days in the Twin Cities of Minneapolis and St. Paul. An added bonus for football fans is that today is Super Bowl LV. My wife and I are not sports fans. We like to bike and walk and occasionally scuba dive. Up to a couple years ago we would watch the half time show. We so not watch TV any more. Perhaps we will find the half time show on YouTube. Continue reading “Sort the Matrix Diagonally in Java”