Basic Calculator II

This is a LeetCode challenge. If interested this is the associated URL:  https://leetcode.com/problems/basic-calculator-ii/?tab=Description

The description of the challenge is short and sweet. This seems to be typical of LeetCode challenges.

Following is a set of screen captures of the console of the Eclipse IDE using the three sample test cases: Continue reading “Basic Calculator II”

Pyramid Max Path

Was talking with a software developer regarding how to determining the max path of a pyramid. We discussed a solution but it is nice to see it come to live.

The following figure illustrates the structure of the pyramid:

 

The requirements are that the height be in the range 1 <= height <= 25. The tree is complete. There are no missing nodes. That implies that the base contains leaf nodes (no children). The values for the nodes should arbitrarily be in the range 1 <= val <= 100. Continue reading “Pyramid Max Path”

Fraction Recurring Decimal

recurring_decimalsFor the past few months I had been working attempting to solve a challenge per day on HackerRank. I like that site. A couple weeks ago I was introduced to LeetCode. Challenges seem to be more intense and requirements seem to be vaguer. Knowing this, one needs to think and plan the approach / algorithm with greater care and expect to fail unit tests that one would not think off. I just finished a challenge and decided to post in this blog my approach to solving it. Continue reading “Fraction Recurring Decimal”

Count Ones

binary_counts_with_fingersHere is a simple task. Given an array of 10,000 random unsigned short integers (16-bit values) count the number of bits set to one (1). In the following example we have an array of two (2) unsigned shorts:

41344 1010000110000000

58520 1110010010011000

The first number 41,344 contains 4 ones and the second value 58,520 contains 7 ones for a total of (4 + 7) = 11 ones. Continue reading “Count Ones”

Multiple Programming Languages

prog-languagesI have dedicated my professional career to different disciplines (i.e., graphics, software engineering) within Computer Science. In this blog entry I would like to summarize some observations regarding computer languages. At different stages in life (e.g., college, work, self study, and business owner) most developers are required or just decide to learn different programming languages. An issue that frequently comes up with project managers is: “Knowing and using multiple programming languages is better or worse for a software developer?” In this blog entry I would like to provide some insights on how to respond to this question. Continue reading “Multiple Programming Languages”

Coding Exercise

cubeEarlier this week I was talking with a colleague about sites that are becoming quite popular with software developers (e.g., HackerRank https://www.hackerrank.com). The format is quite similar between sites. A problem is described. You need to write correct code to solve it.

All have a window in which you can write the necessary code. Most of the constraints for the problem are described. The better sites provide some sample data sets to test your solution. Continue reading “Coding Exercise”