Skip to content

dhony05/Coding_Challenges

Repository files navigation

Java_Challenges

This is a repository for my coding challenges in Java taken from websites like leetcode and codewars, also you will find random challenges which are challenges that I made based on other challenges.

The levels of the challenges are mixed, later I will enumerate them.

      LeetCode challenges
      Random challenges
      CodingBat Challenges(Divided by type of challenge)
      Harkerrank challenges

      Codewars challenges

    1. The most basic encryption method is to map a char to another char by a certain math rule. Because every char has an ASCII value, we can manipulate this value with a simple math expression. For example 'a' + 1 would give us 'b', because 'a' value is 97 and 'b' value is 98. encrypt("a",1) = "b" . (Done: Java)
    2. Given a year, return the century it is in. (Done: Java)
    3. Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.(Done: Java)
    4. Write Number in Expanded Form You will be given a number and you will need to return it as a string in Expanded Form. (Done: Java)
    5. The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 dollars bill. An "Avengers" ticket costs 25 dollars.

      Vasya is currently working as a clerk. He wants to sell a ticket to every single person in this line.

      Can Vasya sell a ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line?

      Return YES, if Vasya can sell a ticket to each person and give the change with the bills he has at hand at that moment.

      Otherwise return NO.(Done: Java)
    6. Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers.

      "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est"

      "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople"(Done: Java)

    7. Given the triangle of consecutive odd numbers:

      1

      3 5

      7 9 11

      13 15 17 19

      21 23 25 27 29

      ...

      Calculate the row sums of this triangle from the row index (starting at index rowSumOddNumbers(1); // 1 rowSumOddNumbers(2); // 3 + 5 = 8 (Done: Java)

    8. You have an array of numbers.

      Your task is to sort ascending odd numbers but even numbers must be on their places. Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.

      sortArray([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4](Done: Java)

    9. In this Challenge you are asked to square every digit of a number.

      For example, if we run 9119 through the function, 811181 will come out, because 9^2 is 81 and 1^2 is 1.

      Note: The function accepts an integer and returns an integer

    10. Given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types.(Done: Java)
    11. In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'.(Done: Java)