Construct the Rectangle

I chose the following challenge from LeetCode: and gave it a try.

f interested please follow the link to get the requirements.

The following is a screen capture of the console using the sample data:

area:        4 = [L:        2 W:        2]

Please note that the challenge only requires the method constructRectangle(). The test cases were generated by me.

Additional output from the console for additional tests follows: Continue reading “Construct the Rectangle”

Symmetric Difference

Received via email a message regarding the following HackerRank challenge:

I liked that a refresher / tutorial preceded the actual challenge.

If interested use the above mentioned link and read the requirements.

Following is a screen capture from the Python console from the Spider 3 IDE: Continue reading “Symmetric Difference”

Bitwise AND of Numbers Range

What a humbling experience. Picked up at random a challenge at LeetCode (

The requirements are quite brief and one can easily determine what is required:

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.

For example, given the range [5, 7], you should return 4”.

I got a piece of paper and jotted down the following: Continue reading “Bitwise AND of Numbers Range”


Received an email from HackerRank to solve a Tuples challenge:

If interested take a look at the requirements.

After reading the requirements, using the Spyder 3.1.0 IDE I came up with a solution which did not have a need for the first line from the Sample Input. The Sample input follows: Continue reading “Tuples”

Remove Duplicates from Sorted List II

This challenge comes courtesy of LeetCode:

The challenge is rated medium difficulty. At this time there have been 96,122 accepted solutions from 334,885 submissions. If you decide to tackle the challenge make sure you read it a few times.

On my first pass (which I did not submit) I missed the word ‘distinct’ from the requirements ;o(

On purpose, my solution completely ignores the fact that the list is ‘sorted. If this would have been work or a contest I would have taken such requirement into consideration :o)
Continue reading “Remove Duplicates from Sorted List II”

Word Pattern

It seems to me that LeetCode ( has more complex challenges than HackerRank ( Their approach to testing the solutions is different. They not only test for correctness but they also check for execution time.

In the next few weeks will concentrate in solving challenges from LeetCode. I will also try to get to weekend competitions if they are relatively early in the day (I am a morning person).

If interested take a look at the requirements for this challenge using the following link: Continue reading “Word Pattern”

Last Python Intro Challenges

Seems like in the past couple weeks I have been getting up earlier than usual. I decided to complete the remaining introduction Python challenges at HackerRank. If you are interested please take a look at the following URL:

For these challenges I decided to use Spyder 3 IDE. I am using:  Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] Continue reading “Last Python Intro Challenges”

Integers Come in All Sizes

I received an email message with a HackerRank challenge. If interested the simple challenge is located at the following URL:

The challenge is quite simple when using Python. Since Python 3 the distinction between integers, long integers and unlimited size integers is gone. In Python 3 an integer could probably take all the virtual memory in your machine ;o). Continue reading “Integers Come in All Sizes”

Python Divmod and Mod Power

I received via email a couple messages with two easy Python challenges named “Mod Divmod” and “Power – Mod Power”. Following are links to the challenges: Continue reading “Python Divmod and Mod Power”