This repository contains my solutions to various HackerRank coding challenges implemented in C++ and C#.
- Array Challenges
- Birthday Cake Candles - Count how many candles are tallest
- Diagonal Difference - Calculate the absolute difference between the sums of diagonals in a square matrix
- Hour Glass - Find the maximum sum of hourglass patterns in a 2D array
- Left Rotation - Rotate array elements to the left by a given number
- Min-Max Sum - Find the minimum and maximum sums of 4 out of 5 integers
- Staircase - Print a staircase pattern of '#' symbols
- String Manipulation
- Love Letter Mystery - Calculate the minimum operations to convert a string to a palindrome
- Palindrome Index - Find which character to remove to make a string a palindrome
- Time Conversion - Convert 12-hour AM/PM format to 24-hour format
- Implementation Challenges
- Designer PDF Viewer - Calculate the area of highlighted text in a PDF viewer
- Angry Professor - Determine if class is cancelled based on student arrival times
- Beautiful Days at the Movies - Count beautiful days based on integer reversals
- Utopian Tree - Calculate the height of a tree after cycles of growth
- Viral Advertising - Calculate cumulative likes from a viral marketing campaign
Each C++ solution can be compiled using g++ and executed separately:
g++ -o <filename_without_extension> <filename>.cpp
./<filename_without_extension>For example:
g++ -o staircase staircase.cpp
./staircaseAlternatively, you can use the VS Code task configured in this repository to build the active file:
- Open the C++ file you want to compile
- Press
Ctrl+Shift+Bto run the build task - Run the generated executable from the terminal
The C# solutions can be compiled and run using the .NET SDK:
dotnet run <filename>.csTo run a specific C# file, you might need to create a temporary project:
mkdir temp-project
cd temp-project
dotnet new console
# Replace Program.cs with your solution code or copy the relevant part
dotnet run├── .vscode/ # VS Code configuration files
├── *.cpp # C++ solution files
├── *.cs # C# solution files
└── README.md # This documentation file