A or B

Over the weekend I watched the YouTube video “Dealing with Negative Comments | AMA #3 – Ask Me Anything with Lex Fridman”. I have watched a few of his videos. I do enjoy them to the point that I have subscribed to them. There is one in which Lex interviews Donald Knuth and other where he interviews Andrew Ng. Both videos are over an hour so I will watch them over the weekend.

If you are interested in getting information about Lex Fridman you can find it here or there.

I picked the challenge “A or B” from HackerRank after receiving an email message. I guess that if you solve a few of their problems they like you to continue visiting their site and solving additional challenges. I like to work on one or two a week. I believe it is the only way to learn and / or refresh material. Continue reading “A or B”

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”

Binary Tree Sum

In this post we will develop a couple methods to collect some information from a binary tree. The first method will be the base, and the second will be an enhancement of the first.

The first requirement is:  given a binary tree with double values, compute the sum of all nodes in the tree.

The second requirement is:  given a binary tree with double values, compute the sum of all nodes whose values are in a specified range (e.g., [ 10.0 : 15.0 ]). Continue reading “Binary Tree Sum”

The Full Counting Sort

306 Subscribers

Today I decided to solve a HackerRank problem. Randomly I selected The Full Counting Sort. If interested read the requirements. I read the requirements and decided to give it a try.

Based on my experience with this problem you might want to follow my advice. Work on the algorithm and make sure it passes the two sample test cases. Once you are done, submit your solution. If you have a valid approach then chances are that your solution will fail test #5, it will time out. I generated up to three different versions of the countSort() function. I could not get past test #5 because it would time out. I spent time reading the discussions and they did not make much sense. I even bought test #5 for some hackos. By the way, the test includes 1,000,000 strings which I could not download no matter how many times I tried. With this problem do not purchase test #5. You will not be able to run it. Continue reading “The Full Counting Sort”

Sum of Two

I received a notification via email that Nicholas White had put a new video in YouTube. If you are interested, the video is named Google Coding Interview Question – Sum of Two. I enjoy working on problems. Try to get a few each week.

Let’s skip the chit chat and go directly to this problem. The statement for the problem follows:

You have two integer arrays a and b, and an integer target value v.

Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v.

Return true if such a pair exists, otherwise return false. Continue reading “Sum of Two”

First Duplicate

This morning in the Twin Cities of Minneapolis and St. Paul we woke up with a temperature of -11 F. The central heating unit worked overtime last night. It was quite dry indoors. Not sure why this happens due to the fact that the central heating as a built in humidifier and air exchange sub systems.

Yesterday morning I read the article “Do You Solve Programming Problems or Complete Exercises? (The Difference Matters.)” by Amy Haddad. She makes a difference between problem-solving and solving exercises. I agree with her interpretation. If interested read her article and possibly comment in her or my post.

Yesterday evening, I was browsing YouTube and ran into the video “Google Coding Interview Question – firstDuplicate” by Nicholas White. Continue reading “First Duplicate”

Cipher

I was somewhat busy over the weekend. My wife and I were going to make some cannoli but for simplicity we decided to bake some chocolate cornetto. We are planning on making cannoli next weekend.

Last week I was reading the web page from Microsoft Dynamics 365 Connected Store. It uses video cameras and IoT devices to capture non-PII (Personally Identifiable Information) from customers that can be used by the store to improve service and increase sales. I spend time reading different related articles and watching YouTube videos. I am impressed with the approach to the subject by Microsoft. Most companies try to incorporate PII data but that may have many implications for the store, customer and the ability to offer the system to customers in different parts of the world due to local laws. I can go on and on but that would take us out of the topic for this post. Continue reading “Cipher”

Sansa and XOR

I just got off the phone with my youngest son. He was on his way to work. He calls every workday and I call him every weekend. It has become some type of tradition. Today the weather in the Twin Cities of Minneapolis and St. Paul is sunny and cold with the temperature at 11 F. In Madison, WI it is a few degrees warmer. Continue reading “Sansa and XOR”

Mini-Max Sum

This week is starting to build as a very interesting and important one. Hopefully things will work out best.

My sister has been working in China for about four years. Currently she is a professor of medicine at Tsinghua University in Beijing, China and a professor of cellular molecular physiology and internal medicine at Yale University in New Haven, CT. Last time we communicated she was going to travel from Beijing to New Haven during the first week of February.

As far as I know the Coronavirus is still not under control. Today I read that the Chinese government had completed the building of a new hospital with 1,000 beds in the city of Wuhan. Hopefully that will help providing care for the people that contracted the virus. Continue reading “Mini-Max Sum”

A* Search Algorithm

As I mentioned in my last post, I read the article “A* search: what’s in a name?” by James W. Davis and Jeff Hachtel. If interested, you may find the article in Communications of the ACM, December 2019, Vol. 63 No. 1, Pages 36-37. The article deals with the name of a search algorithm that was originally published in 1968 by Peter Hart, Nils Nilsson and Bertram Raphael of Stanford Research Institute.

My interest was not much about the name but to be able to experiment and understand the algorithm. There are so many algorithms in Computer Science that adding one more to my list is always welcomed. I do not plan on memorizing the algorithm but if the time comes when I might need to search a graph, I will have one more choice in my toolkit. Continue reading “A* Search Algorithm”