Longest Absolute File Path – C# and Java – Revisited

Hope you had a nice Thanksgiving day with family and friends. My wife and I typically roast a turkey. This year, for the first time, we went with a fresh turkey breast. It was a fraction of the weight of a full turkey and when all was said and done, my wife did not have to deal with cleaning the bones. Today, and probably for the next few days, we will be having different types of turkey sandwiches (Bread, butter on the outside, panini press @ 350F, turkey meat. When brown and crunchy, open sandwich, apply mayonnaise and a touch of mustard. Close and enjoy).

In this post I will revisit solving LeetCode 388. Longest Absolute File Path. The motivation was a message I received a few days back on a solution in O(n). I looked up my solution in Java from February 27, 2017 and it was hard to follow. At the time I used a different plugin and the output was not that great. With time it stopped working so I switched to a different one. Much better but sometimes it mangles the output. Continue reading “Longest Absolute File Path – C# and Java – Revisited”

Software Engineering at Google Lessons Learned from Programming Over Time

Good day, it has been a while since my last post. Have been quite busy at work and home. The holidays are approaching so things might improve somewhat.

In this post I am not going to write code. I am going to let you know about things that called my attention in the past few weeks.

I am currently reading “Software Engineering at Google Lessons Learned from Programming Over Time”, curated by Titus Winters, Tom Monshreck & Hyrum Wright, published by O’Reilly. And yes, it is the book with the pink flamingo on the cover. Continue reading “Software Engineering at Google Lessons Learned from Programming Over Time”

LeetCode 142 Linked List Cycle II in Java

In this post I will be solving LeetCode 142 Linked List Cycle II using the Java programming language.

This problem seems to be the continuation of a problem we solved earlier LeetCode 141 Linked List Cycle in Java in this blog. Perhaps you would like to read it before attempting to solve the problem in this post.

Given the head of a linked list, 
return the node where the cycle begins.
If there is no cycle, return null.

There is a cycle in a linked list if there is some node in the list that 
can be reached again by continuously following the next pointer. 

Internally, pos is used to denote the index of the node that tail's next pointer is connected to (0-indexed).
It is -1 if there is no cycle.
Note that pos is not passed as a parameter.

Do not modify the linked list.


o The number of the nodes in the list is in the range [0, 104].
o -10^5 <= Node.val <= 10^5
o pos is -1 or a valid index in the linked-list.

Related Topics:

o Hash Table
o Linked List
o Two Pointers

Follow up:

Can you solve it using O(1) (i.e. constant) memory?

We are given a singly linked list which may or may not have a cycle. We need to return `null` if it does not contain a cycle, or the node where the cycle begins. The LeetCode web site contains some diagrams to better illustrate the linked lists with a cycle. Continue reading “LeetCode 142 Linked List Cycle II in Java”

LeetCode 445 Add Two Numbers II in Java

In this post we will solve the LeetCode 445 Add Two Numbers II problem using the Java programming language. We will generate two implementations of the function in question. The first will use two stacks while the second will reverse the singly linked list. When reversing linked lists we will implement an iterative and a recursive set of functions.

You are given two non-empty linked lists representing two non-negative integers. 
The most significant digit comes first and each of their nodes contains a single digit. 
Add the two numbers and return the sum as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.


o The number of nodes in each linked list is in the range [1, 100].
o 0 <= Node.val <= 9
o It is guaranteed that the list represents a number that does not have leading zeros.

Follow up:

o Could you solve it without reversing the input lists?

Related Topics:

o Linked List
o Math
o Stack

We are given two singly linked lists with digits representing two non-negative numbers. We need to return their sum in a singly linked list. If interested in this problem I suggest you visit LeetCode and get the current version of the problem. Sometimes the requirements are updated. Continue reading “LeetCode 445 Add Two Numbers II in Java”

Number of Islands – Java

Last evening before going to bed, I left a window in the kitchen opened just a crack. The temperature was forecasted to drop down to 37F, so I hopped it was going to be fine.

A few minutes past midnight I woke up. It felt somewhat chilly. I closed the window and checked the temperature in the upper level zone. It was at 68F which is at what we keep it during the winter months. I turned on the heat in the zone and went back to bed. During the rest of the night I heard the furnace kick in a couple times.

During breakfast my wife asked if windows were closed and the furnace was on. I told her about my midnight adventure. We agreed on leaving windows closed from now on until next spring. The system at home has an air exchange unit so it makes sense to keep the windows closed and the temperature at 68F. Continue reading “Number of Islands – Java”

Masking Personal Information

Earlier this morning while having breakfast with my wife, around 06:30 AM she noted that the day was quite dark. I replied that this is normal this time of the year, especially because Daylight Savings in the United States was extended since the last update.

Around 07:00 AM, after showering and getting dressed, I descend to my home office. Around 10:00 AM I prepared coffee for my first break of the working day. It was sunny and windy with a temperature in the high 40’s. Hopefully the weather will remain like that for the rest of the day.

While browsing the LeetCode web site problem 831 Masking Personal Information called my attention. I develop software and systems that deal with medical records and images which need to be de-identified. This problem seemed to contain a very reduced set of data that needs to be anonymized. Continue reading “Masking Personal Information”

TDD is Seldom Understood


I read and re twitted the post by Chris Fox titled “Test-Driven Development is Fundamentally Wrong” in Hacker Noon. In the past few months, I have been reading multiple articles a day about TDD. It seems to me that most people (i.e., software engineers and software managers) have heard about the benefits of using TDD, but it all collapses when understanding and applying the proper concepts or fundamental nature. Continue reading “TDD is Seldom Understood”

Flatland Space Stations

Please do not be shocked by the introductory sentences. I was born into an Italian family. My parents moved from Italy to Peru in the 1930’s. Growing up in Peru we were introduced to have wine with weekend meals. In particular wine was only served for lunch. My sisters and I started drinking lemonade with wine. After a few years we moved to have a desert that is made of fresh strawberries with sugar and wine. You just mix the ingredients and let them sit for a couple hours in the fridge. If you try it this summer, make sure it is served chilled. As we got older we had weekend lunch with a couple bottles of wine. None of us ever had issues with alcohol. Different cultures have different approaches to solve the same issue. We just need to make sure that what we do works to solve the problem. If it does not, learn and put practice different approaches. This philosophy can and should be applied to life and software development. Continue reading “Flatland Space Stations”

Binary Tree – Heap

I read an article or two from Medium every day. A few days ago I read “Binary Trees: The Heap” by David Pynes. The idea behind a binary tree or heap is to be able to associate values with associated priorities. For example, assume you are in line at an emergency room in a hospital. When you arrive and register the facility may use a plain queue (FIFO) to wait for a physician. What happens if a patient in worse condition that you arrives later. The logical thing would be to allow them to see a physician before patients that are less ill. Continue reading “Binary Tree – Heap”

Echo Server and Client

This past winter was quite long but not too cold. A few weeks ago we received a one two punch with two winter storms. After that the temperatures went up and we had a day with temperatures in the mid 80s. In the past week the temperatures were down. Last night we were in the lower 40s. We turned off the central heating system at home for the season. We have already been using the air conditioner for a few days. This morning the inside temperature upstairs was 66 F. My home office is downstairs. The temperature has been at a solid 60 F so far. My wife and I are planning on going for a walk in a couple hours. Continue reading “Echo Server and Client”