Ad
  • Custom User Avatar

    Totally agree man, and well thanks for starting the initiative and giving lead on this one, helped a lot.

  • Default User Avatar

    Some edge case tests are missing at least in Python:

    This solution fails at:

    Testting for 'DPPDP', the correct result should be -1: 4 should equal -1

    but it passes all tests sometimes.

  • Custom User Avatar

    In my opinion description is a bit unclear and written in a way that is misleading / difficult to understand

    Here's a simplified version of the task description:

    "You have a string made up of the letters 'D', 'P', and 'C'. Your task is to find the smallest positive number, N, that satisfies certain rules based on the string. Here are the rules:

    For each position in the string (let's call this position 'i'), do the following based on the character at that position:

    • If the character is 'D', the number N should be divisible by 'i'. In other words, when you divide N by 'i', there should be no remainder.
    • If the character is 'P', the number N should not share any common factors with 'i', except for 1. This means that N and 'i' don't have any divisors in common other than 1.
    • If the character is 'C', the number N should NOT be divisible by 'i' (meaning there is a remainder), and also N should share some common factor with 'i' other than 1.

    Find the smallest number N that satisfies all the rules for the given string. If no such number exists, return -1. The number N should be less than or equal to 1 billion (1,000,000,000)."

  • Custom User Avatar

    Wouldn't it be better to add in the description that the correct answer for middlePyramid is 1074 not 1064? As many people thinks it's an issue it would laso be good to add some hints like that it is based on "Greedy algorithm" or that you should use dynamic programming technic to solve it? I understand that it is good practive to look for an answer however in order to catch a fish you need a fishing rod first.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Don't look at it

  • Custom User Avatar

    I'm also getting a timeout error, cause of the large numbers.

  • Default User Avatar

    if they have the same weight,ypu have to compare them according string ascii code

  • Custom User Avatar

    I googled basic java stuff bc I forgot a lot of stuff but nothing specifically related to the problem does that count 😂

  • Custom User Avatar

    I already admitted to mistake. There is no need to continue this topic.

  • Custom User Avatar

    @VaxiZ: with your reasoning, nothing's wrong with bogosort, which is, to say the least, arguable.

  • Default User Avatar

    FWIW I have the complete opposite view; I think it's amazing to realise that mathematicians working hundreds of years ago with pen and paper (or even thousands of years ago using sticks in the sand like Euclid) could come up with "algorithms" that are faster than what a decent brute-force programmer can do with a modern computer -- if that isn't motivation to learn more from the "math" katas, I don't know what is!

    Also, nothing wrong with Opel Astras >:(

  • Default User Avatar

    Try harder. (Or less harder) The solution is easier than it seems.

  • Custom User Avatar

    The worst code I have ever written... I am proud of it

  • Default User Avatar

    I glanced at the solutions and saw a top answer used

    if (array[0].length == 0) { return new int[0]; }

    which is a little simpler than what I tried

  • Loading more items...