Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Feeling not so good right now haha. Just insane!

  • Custom User Avatar

    I just passed this in C and I'm socked at how bad my solution was. It was just a complete over complication of a very simple math related question. I really need to improve my math intuition on questions like these. Thanks for this great kata!

  • Custom User Avatar

    Ok, I will look into it. Thanks so much for the help!

  • Default User Avatar

    This might help streamline your code: The input will be a lowercase string with no spaces. I'd malloc the strings thus: (stringLen + 1) * sizeof(char). Nonetheless, this code would work if you handle your C-strings correctly.

  • Custom User Avatar

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

  • Default User Avatar

    can't tell exactly without seeing your code, but my bet is on whether you allocated memory correctly. you may post your code with proper markdown and a spoiler tag, and I can take a look for you.

  • Custom User Avatar

    I hope to ask someone for help with this problem. I implemented a solution in C but during the random tests, one or more of the tests fail. Looking into my solution I'm very sure that the code is solving the problem correctly. Here are some results from my code, using random inputs of my own:

    input: abcdefghijklmnopqrstuvwxyz
    output: 
     AbCdEfGhIjKlMnOpQrStUvWxYz
     aBcDeFgHiJkLmNoPqRsTuVwXyZ
    
    input: okwwkspoginevairavzasqukvubmhkjq
    output: 
     OkWwKsPoGiNeVaIrAvZaSqUkVuBmHkJq
     oKwWkSpOgInEvAiRaVzAsQuKvUbMhKjQ
    
    input: mgewjuzacjjlkyjlxcirwxwtwjwwiaxh
    output: 
     MgEwJuZaCjJlKyJlXcIrWxWtWjWwIaXh
     mGeWjUzAcJjLkYjLxCiRwXwTwJwWiAxH
    
    input: mgewj   uzacjjlkyjlxcirwxwt   wjwwiaxh
    output: 
     MgEwJ   UzAcJjLkYjLxCiRwXwT   WjWwIaXh
     mGeWj   uZaCjJlKyJlXcIrWxWt   wJwWiAxH
    
    input: 9{cym.gftj&$nb8e
    output: 
     9{CyM.GfTj&$Nb8e
     9{cYm.gFtJ&$nB8E
    
    input: jku72&bs_j-63dr@a?#7x54?a^y
    output: 
     JkU72&Bs_j-63dR@A?#7X54?A^Y
     jKu72&bS_J-63Dr@a?#7x54?a^y
    
    input: rq7Ej#ahHXgJ2+q#
    output: 
     Rq7eJ#AhHxGj2+Q#
     rQ7Ej#aHhXgJ2+q#
    

    What am I missing? Thanks!

  • Custom User Avatar

    No need to apologize :-)

  • Default User Avatar

    Vernon, it wasn't a criticism, just was curious as to why you chose to do it that way. My apologies if it came out as insulting. :(

  • Custom User Avatar

    Thank you very much for the information. I'm new to Java and am still learning. You are correct I'm really not sure why I did this but now after reading your comment I can see how stupid it was. Thanks once again.

  • Default User Avatar

    Why are you doing it this way? You know under the covers that ArrayList essentially has to re copy when it allocates more space when the underlying array runs out of space right? Which is O(n) + NLog(n);

    Then additionally you're going to call toArray, which is going to do another scan of the full size, so your time complexity will be O(2n) + n(log(n)) and your space complexity will be O(2n) one for the arraylist and one for the array...

  • Custom User Avatar

    Good example of return statements and codeflow for bigginers. I Like :-)