LeetCode 171. Excel Sheet Column Number in Java

In this post we will solve LeetCode 171Excel Sheet Column Number problem using the Java programming language.

If interested in this problem, I suggest you go to the LeetCode website and read the description of the problem in case something has changed. If you are still interested please read on.

Given a string columnTitle that represents the column title as appear in an Excel sheet, 
return its corresponding column number.

For example:

A -> 1
B -> 2
C -> 3
Z -> 26
AA -> 27
AB -> 28 


o 1 <= columnTitle.length <= 7
o columnTitle consists only of uppercase English letters.
o columnTitle is in the range ["A", "FXSHRXW"].

Related Topics:

o Math
o String

The problem is relatively simple. We are given a string of uppercase characters each of which represents a digit in base 26. We need to compute the integer value associated with the string. Continue reading “LeetCode 171. Excel Sheet Column Number in Java”

LeetCode 191 Number of 1 Bits in Java

In this post we will solve the LeetCode 191 Number of 1 Bits problem using the Java programming language.

Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).


Note that in some languages, such as Java, there is no unsigned integer type. 
In this case, the input will be given as a signed integer type. 
It should not affect your implementation, as the integer's internal binary representation is the same, 
whether it is signed or unsigned.
In Java, the compiler represents the signed integers using 2's complement notation. 
Therefore, in Example 3, the input represents the signed integer. -3.


o The input must be a binary string of length 32.

The requirements call to develop a function that takes as an argument an unsigned integer and returns the number of bits set to 1. Note that the integers have 32-bits. Continue reading “LeetCode 191 Number of 1 Bits in Java”


Good morning! Hope your day has started on the right note.

In this post we will attempt to solve the Codility_ problem MaxProductOfThree using the Java programming language and the VSCode IDE on a Windows platform. We will not be using the online IDE provided by Codility_ since we will write the code on a separate computer. Continue reading “MaxProductOfThree”

High Point in Array

Good morning! It is Friday and the weekend is just around the corner. In the Twin Cities of Minneapolis and St. Paul we received our first snow dusting of the season. Yesterday early morning I drove my wife to a healthcare facility to get a radiological exam. Traffic was heavier than what we expected. We got back home around 09:00 AM. The rest of the day ended for me at 19:00 PM. It was a very long and exciting day.

As the weather changes, I have slightly modified my workdays. I work in 2-hour blocks. The blocks are dictated by the EyeDefender app. I tend to work four to five blocks during the week and one to two on weekends. After each block I get on a stationary bike and pedal backwards for about two minutes and forward for six. This gives me over half an hour of exercise per day and half on weekends.

Starting this week, I will not stop immediately after EyeDefender tells me to do so. Will continue with the bike exercise after each block. Doing this will reduce the blocks to four on workdays. I guess it is better to continue working past the two hours until I reach a normal breaking point based on the task at hand. Will let you know my findings as far as productivity is related early next year.

One last thing, most of the times that I generate a post, I check on the number of subscribers. Today’s count is 10,025 subscribers Thanks a lot!!! This implies that in the very near future I will, in addition to this post, start a YouTube channel with similar content or will just switch to YouTube and discontinue this blog. One way or the other, I will be getting the necessary video hardware and software tools, and will start experimenting with them. I am planning on having the YouTube channel up and running by January 2022. Continue reading “High Point in Array”

Permutation in String

Good morning! Hope you had a nice weekend. My wife and I did. We did some shopping, visited our son, and baked. For some reason last winter we did little baking. Yesterday morning after completing a two-hour block in my home office, I went up, prepared coffee and sat with my wife to chat. The subject of baking came up. Baking is both knowledge and art. In general when cooking or baking we tend not to follow recipes. Yesterday we collected the ingredients for raisin cinnamon bread around 09:00 AM. I got the dough ready around 10:00 AM. The dough proofed for a few hours and early afternoon, while my wife was preparing an avocado with tomatoes and roast beef salad, I buttered four bread molds, poured in the bread batter, waited for about 15 minutes (should be  an hour), and baked the cinnamon raisin bread. It turned out very good, but next week, I will let the bread proof for an hour in the molds. While the bread was still hot, we had two slices each with soft butter and grape jelly made by our daughter in law. It was delicious and to be honest with you, it does not require much work. Continue reading “Permutation in String”

Remove the Nth Node From End of List

Happy Friday! It is a typical fall Friday in the Twin Cities of Minneapolis and St. Paul. When I woke up this morning the outside temperature was 38F. The forecasted high for the day is 56F. Tomorrow the forecasted high temperature will be 67F. Will check with my wife if we will grill outside. Not too many grilling days left this year.

Earlier today I read the article Big whales eat 3 times as much as previously thought, which means killing them for food and blubber is even more harmful to the environment by Marianne Guenot. I also read a different article on the same subject titled The Enormous Hole That Whaling Left Behind by Ed Yong. Both articles are in agreement with the research and published papers. As humans, the idea of fertilizing the waters in specific areas seems to be a good thing to do now that the amounts of iron to use have been accurately estimated. Perhaps in the next few decades the oceans will see whales in the numbers they existed 60 years ago. Continue reading “Remove the Nth Node From End of List”

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”

Two Sum II

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”

Squares of a Sorted Array

Today has been a very busy and stressful day. This morning when I woke up around 06:00 AM I could hear the second zone in the heating system running. That zone includes the lower level at home. While having breakfast it bothered me that the output of the furnace was still sending heat to the second zone. I went down and noticed that the furnace was not working properly. We had an issue last Friday which was fixed Monday afternoon. Apparently the issue was not properly addressed.

I asked my wife to call the company that worked on the furnace. They could not send us a technician today so she called a different company. Hopefully the technician will stop by this afternoon. It is shortly past 05:00 PM and the furnace technician has not arrived. I guess he will be here tomorrow. The good news is that we can keep the house quite warm using the lower level fireplace.

This morning while doing some on-line research, I ran into the  Documentation OData 4.0 Java Library. Apache Olingo is a Java library that implements the Open Data Protocol (OData). Apache Olingo serves client and server aspects of OData. It currently supports OData 2.0 and will soon support OData 4.0. The latter is the OASIS version of the protocol: OASIS Open Data Protocol (OData) TC. Planning on experimenting with it in the next few days.

Since a week ago I have been writing this post on Google Docs. When done I save a copy in .docx format on a Windows machine. I used to write posts using Word. Continue reading “Squares of a Sorted Array”

First Bad Version

As I mentioned in my last post, over the past weekend my wife and I visited my younger son who lives in Madison, Wisconsin. At some point during a conversation personality types came up. We spent an hour or so on the subject. Towards the end my son’s wife mentioned an article on the subject she found by doing a web search. I asked her to send us the link. She did. I will read the article later today and will comment on my next post.

The technician that was going to fix the issue with our furnace showed up on time. I decided to watch him at work. He opened the furnace and cleared some dead wasps that had come in through the air intake tube. The furnace started to work. He spent some additional time cleaning contacts to increase the current flow.

It seems that our furnace is getting to the point that it will be needing a replacement soon. The technician gave us quotes for three different models. If the furnace continues to operate as intended we would be replacing it towards the end of Spring 2022.

Last night the furnace worked as expected. This morning I increased the temperature setting to the lower level. I li9ke to keep my office at 65F. The rest of the house is set to 68F during winter.

As I am typing this post the “Machine Learning for Algorithm Design” by Maria-Florina Balcan ACM webinar is starting. I will continue with this post as soon as I am done attending the 1-hour event.

OK, I am back. Would like to finish this post before lunch time. Continue reading “First Bad Version”