Concurrent Skip List Map

Before we start I would like to thanks all of you that have subscribed to my blog. We have reached 2,000 subscribers!!! As a matter of fact, we currently have 2,150 subscribers. Thanks a lot!!!

It is so hard to find real news not politically opinionated. For example, I ran into an article that discussed the AztraZeneca vaccine trial in the UK. Apparently there have been two cases in which people that received the vaccine got severely ill. In both cases the trial stopped until further investigation. In both cases it was determined that the issue was not associated with the vaccine. The trials continued in the UK. Continue reading “Concurrent Skip List Map”

Student Attendance Record I

Woke up today at 04:20 AM. It was raining. Spent some time reading and on this blog and at 06:00 time to make the donuts (actually breakfast).

Since I had not much time I did a search on LeetCode problems using the string “recursion”. Problem 551. Student Attendance Record I came up. I did not see the need to use recursion and the problem does not specify to use it either. Continue reading “Student Attendance Record I”

Get Returned Type – Java

In general when you are developing software you need to have a good idea of the different classes that are needed and for each class the members and methods. Under some special circumstances you might run into classes that are not documented and you need to get some information as to the returned values. Please bear with me attempting to provide a good example. In practice most of the time (do not generalize) you will have such information displayed in your IDE or in documentation provided by the vendor. Continue reading “Get Returned Type – Java”

Sum Two

This weekend my wife and I spent it in Madison, Wisconsin visiting our son and family. We left Friday after work and returned Sunday afternoon. The drive is between 3.5 and 4.0 hours depending on traffic. Given that we are in the middle of the COVID-19 pandemic, we were amazed at how much traffic we encountered.

Last Friday morning I took a look into a couple problems but did not have time to write the associated posts. I will do if I have some time in the near future. Note that I have already addressed a similar problem in my post Sum of Two earlier this year.

In this post I will cover a problem I searched for on the web. This problem comes in different flavors. I found the one on LeetCode so I decided to take a stab at it. Continue reading “Sum Two”

Combinations

Hello gals and guys! It seems that during the COVID-19 pandemic time goes faster. It is Saturday and the work week went by in the blink of an eye.

This post was motivated by a HackerRank problem which I am getting ready to tackle. I decided to experiment with combinations and factorials to make sure that a brute approach to the actual problem would be futile. In my next post will tackle the basis for a better approach.

As usual let’s start with some chitchat. Continue reading “Combinations”

Tree Preorder Traversal

Good morning! It is a sunny and warm Sunday morning in the Twin Cities of Minneapolis and St. Paul. Yesterday due to high temperature and humidity concerns, my wife and I decided to start lunch earlier than usual. We finished our mid morning cup of triple espresso around 11:00 AM.

My wife made some nachos. She used small tortilla chips, and a block of Colby-Jack cheese which she shredded in the Ninja blender. For the salsa she used one or two avocados, some jalapenos from a jar and some Pace picante medium strength sauce. The plain tortillas with the cheese were placed in a 350 F oven for about 20 minutes. That melted the cheese. Continue reading “Tree Preorder Traversal”

Down to Zero – Revisited

!!! NOTE !!!

Not sure what happens with the formatted code which seems to display well and sometimes it does not. The good thing is that the entire code is in my GitHub repository. Sorry about the inconvenience. If you have a formatter for Word Press that you like and is reliable, please let me know.

I received a message from a reader of my blog requesting some clarification on my original solution and associated post Down to Zero II. The associated post was from 2016. The initial code was not in my GitHub repository. Sorry about that.

After reading the message (which I keep private unless told otherwise) I went to GitHub and created a new repository. I added a short and simple README.md file and cloned the repo to one of my Windows 10 computers.

I then copied the original solution.java file and opened it using VSCode. The original code was developed using the Eclipse IDE. In the past year or so I have switched to VSCode for C++, Java, and Python. Continue reading “Down to Zero – Revisited”

Shuffle Array – Java

Every work day when quitting time approaches (around 05:00 PM) I check my to-do list. One thing I had for the day was to check is there is a method in a Java class to shuffle the contents of an array. This is a nice mechanism to have in your toolbox. For example, if you want to load a binary tree search (BST) and the data is sorted, the tree will basically load like a linked list. In a BST you can typically find an element in O(log(n)). But if the elements were inserted sorted, the search is performed in O(n) which is slower than O(log(n)). In such cases you can just shuffle the array and then load the BST. Continue reading “Shuffle Array – Java”

Is Permutation

Let’s define the requirements for this algorithm. We are given two sets of integers. The idea is to check if the sets are permutations of each other. If they are, return YES; otherwise return NO.

First let’s make sure we agree with the definition of permutation. For the sets to be permutations we must have the same number of elements in both sets. Each set must have the same counts for each entry. For example if the sets are:

1 2 3 4 5 6

6 5 4 3 2 1

Then we would return YES. Both sets have the same length (six in this case) the numbers are the same on both sets, and the count of each number matches (one in this case).

7 6 5 0 9 7

7 6 1 0 9 7

Given that 5 is in the first set, but not in the second and 1 is in the second, but not in the first, these are not permutations of each other so we would return NO. Continue reading “Is Permutation”

Java Streams

A few minutes ago my wife called me up to the kitchen to help her. She needed Grand Maniere for an Italian nonna’s apple cake she was making. In addition to the apples, she likes to add raisins soaked in liquor. She decided to use Grand Maniere because she found a large bottle in the liquor cabinet. She could not remove the cork so she called me for help. As I was attempting to open the bottle I asked if she remembered when we got it. It seems that we bought the bottle when we lived in Maryland; that was many years ago.

The cork disintegrated when I was opening the bottle. The bottle was standing up and with the years the cork dried up. We keep our wines in an angle in our cellar, but the hard liquor in our cabinet is standing right side up. We seldom consume hard liquor. The Grand Maniere smelled fine and my wife was able to soak the raisins. Each time she fixes this dessert she tries to make it a little different. In my opinion, apples, raisins and walnuts go very well together. Will let you know in my next post how this cake turned out. Continue reading “Java Streams”