Skip to content

aysedemirel/HackerRank-JavaChallenge

Repository files navigation

HackerRank-JavaChallenge

Contributors Forks Stargazers Issues License LinkedIn


Logo

HackerRank-JavaChallenge

HackerRank Java Challenge Solutions

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Key Takeaways
  4. Roadmap
  5. Contributing
  6. Contact

About The Project

This project includes solutions to Java problems on the HackerRank platform. While solving the problems, you can both practice Java and take a look at problem-solving techniques. I will present different solutions according to Worst, Average and Best Case analysis in problem-solving. Thus, we will be able to analyze the algorithm we created while solving the problem. While the codes of the problem solutions are here, you can find detailed explanations on my Medium account.

Medium- HackerRank Solutions

(back to top)

Built With

  • made-with-java

(back to top)

Getting Started

In this project, each class has its own main method. You can copy the codes in the main method directly to the area on HackerRank to solve problems via HackerRank.

Prerequisites

Prerequisites to run the project:

  • Java 19
  • Maven

You can download and install JDK from this link, and you can also find a sample installation document on how to install the JDK. To download Maven, you can refer the link.

Installation

How to download the project:

  1. Clone the repo
    git clone https://github.com/aysedemirel/HackerRank-JavaChallenge.git
  2. Install Maven packages (Via IDE or mvn install)

Executing Program

How to run the project:

  • Each class works independently
  • Each class compile with the code (or just via IDE):
    javac ClassName
  • After compiling, run the bytecode:
    java ClassName

(back to top)

Key Takeaways

Introduction

Scanner's skip Method: The skip method in Java's Scanner class allows you to skip specific patterns defined by regular expressions. It's useful when you need to filter out certain unwanted characters from a String input. For more details on the skip method and regular expressions, refer to GeeksforGeeks.

HackerRank's Java If-Else Challenge: The provided starter code for the Scanner includes a skip method with the following pattern: (\r\n|[\n\r\u2028\u2029\u0085])?. This pattern is used to handle various line-ending characters. For an in-depth explanation, check out this Stack Overflow post.

Eclipse End-of-File Issue: When using Eclipse, handling the end-of-file (EOF) with scanner.hasNextLine() can be tricky. The Ctrl + Z shortcut is used to indicate EOF, but you need to click outside the console (e.g., on the editor) and then back into the console for it to work properly.

Strings and Regular Expressions

Regex Basics:

  • \d: Represents any digit (equivalent to [0-9]).
  • \d{1,2}: Matches any one or two-digit number.
  • (0|1): Matches either 0 or 1.
  • [0-5]: Matches any single digit between 0 and 5.
  • ^: Asserts that the match must start at the beginning of the string or line.
  • $: Ensures that the match must occur at the end of the string or just before \n.

For More Information: Further reading on regular expressions can be found at GeeksforGeeks.

You can access my detailed write-ups and step-by-step solutions for all the problems through the following links:

(back to top)

Roadmap

  • Introduction
  • Strings
  • BigNumber
  • Data Structures
  • Object Oriented Programming
  • Exception Handling
  • Advanced

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Top contributors:

contrib.rocks image

(back to top)

Contact

Ayşe Demirel Deniz - Linkedln - aysedemirel - [email protected]

(back to top)