Ad
  • Custom User Avatar

    That is part of the trap of this problem: When you start raising numbers to exponents they can get really big really. If you have a big number (exponent of 7 or 8) and there are a couple of 9's in there you might get a result larger than an int can hold. If only there was an integer type that could hold something longer than a regular int could hold......

  • Custom User Avatar

    The way you determine your return value is redundant: "if true return true else return false". You can simplify that by just returning the result of the comparison (result == value).

  • Custom User Avatar

    I tend to agree with some of the other comments: this solution works for small arr arrays. As the length of arr increases this would become much less efficient (I think O(n^2)?). The other solutions are using a dictionary to overcome this possible bottleneck, since a dictionary is implemented as a hash table.

    Good solution overall though. The counting of the occurrences is the only thing I would change.

  • Custom User Avatar

    Good Kata! As for the C# solution it would be nice if the starting template included "using System.Collections.Generic;" Not a terribly difficult thing to overcome, but it makes sense to me that the solution template would compile by default.

  • Custom User Avatar

    I agree - returning an empty list (at least in C# and apparently Java) makes the solution much more compact/elegant. I think it could be argued that you should just return a single element list with the length/width as a member.