This repository contains a collection of problem-solving solutions for the HackerRank website. It serves as a practice ground for sharpening your coding skills and tackling various algorithmic challenges.
-
- Description: Given an array of integers, find the sum of its elements.
- Solution: SimpleArraySum.cs
- Unit Tests: SimpleArraySumTests.cs
-
- Description: Given two arrays of integers representing Alice's and Bob's ratings for various aspects, compare their ratings and determine the winner.
- Solution: CompareTheTriplets.cs
- Unit Tests: CompareTheTripletsTests.cs
-
- Description: You are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
- Solution: AVeryBigSum.cs
- Unit Tests: AVeryBigSumTests.cs
-
- Description: Given a square matrix, calculate the absolute difference between the sums of its diagonals.
- Solution: DiagonalDifference.cs
- Unit Tests: DiagonalDifferenceTests.cs
-
- Description: Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with 6 places after the decimal.
- Solution: PlusMinus.cs
- Unit Tests: PlusMinusTests.cs
-
- Description: The Staircase problem involves printing a pattern of '#' symbols representing a staircase of a given height 'n'. Each line contains a specific number of '#' symbols, forming a staircase shape.
- Solution: Staircase.cs
- Unit Tests: StaircaseTests.cs
-
- Description: Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
- Solution: MiniMaxSum.cs
- Unit Tests: MiniMaxSumTests.cs
-
- Description: Given a time in 12-hour AM/PM format, convert it to military (24-hour) time.
- Solution: TimeConversion.cs
- Unit Tests: TimeConversionTests.cs
-
- Description: Given a year, y, find the date of the 256th day of that year according to the official Russian calendar during that year. Then print it in the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.
- Solution: DayOfTheProgrammer.cs
- Unit Tests: DayOfTheProgrammerTests.cs
- Description: It should print Bon Appetit if the bill is fairly split. Otherwise, it should print the integer amount of money that Brian owes Anna.
- Solution: BillDivision.cs
- Unit Tests: BillDivisionTests.cs
- Description: You have an empty sequence, and you will be given queries.
Each query is one of these three types:
1 x -Push the element x into the stack.
2 -Delete the element present at the top of the stack.
3 -Print the maximum element in the stack. - Solution: MaximumElement.cs
- Unit Tests: MaximumElementTests.cs
- Description: Find the maximum possible height of the stacks such that all of the stacks are exactly the same height.
- Solution: EqualStacks.cs
- Unit Tests: EqualStacksTests.cs
- Description: Given the initial value of grades for each student, write code to automate the rounding process.
- Solution: GradingStudents.cs
- Unit Tests: GradingStudentsTests.cs
- Description: Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to 1.
- Solution: PickingNumbers.cs
- Unit Tests: PickingNumbersTests.cs
- Description: Two cats and a mouse are at various positions on a line You will be given their starting positions. Your task is to determine which cat will reach the mouse first, assuming the mouse does not move and the cats travel at equal speed. If the cats arrive at the same time, the mouse will be allowed to move and it will escape while they fight.
- Solution: CatsAndAMouse.cs
- Unit Tests: CatsAndAMouseTests.cs
- Description: There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. Return an array of the results.
- Solution: SparseArrays.cs
- Unit Tests: SparseArraysTests.cs
- Description: Given n strings of brackets, determine whether each sequence of brackets is balanced. Return YES, if the string is balanced. Otherwise, return NO.
- Solution: BalancedBrackets.cs
- Unit Tests: BalancedBracketsTests.cs
- Description: Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.
- Solution: ArrayManipulation.cs
- Unit Tests: ArrayManipulationTests.cs
Feel free to explore the solutions in the respective directories for each problem.
Contributions to this repository are welcome! If you would like to add solutions for more problems or improve existing solutions, follow these steps:
- Fork the repository.
- Create a new branch for your contribution.
- Implement your solution or make the desired improvements.
- Test your code to ensure it works correctly.
- Commit your changes with descriptive commit messages.
- Push your branch to your forked repository.
- Submit a pull request to the main repository.
Please ensure your code follows good coding practices and include any necessary documentation or explanations.
This project is licensed under the MIT License.