sudeep065/string-data-algorithms-collection
This is a code collection of all the String Manipulation data algorithms with the sample input and output.
Table of Contents
Terminal Commands
This project was generated with Console using Visual Studio 2019 Free Version click to download version 16.8.4
Simple-Superreduced
Complete the superReducedString function below
Sample Input
string="aaabccddd"
Sample Output
abd
Explanation- Remove next matching char, if its just repeated 2/4 times then remove completely, if itz odd numbers, then you we need to keep it.
aaabccddd -> aabccddd -> abccddd -> abddd -> abdd -> abd
RepeatedString
There is a string s, of lowercase English letters that is repeated infinitely many times. Given an integer n,find and print the number of letter a's in the first n letters of the infinite string.
Example Input
aba
10
Sample Output
7
Explanation 0
The first n=10 letters of the infinite string are "abaabaabaa". Because there are 7 a's, we return 7.
Efficient HackerRank solutions in C# programmed by Sudeep
10 Days of Statistics
Algorithms
Implementation
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| ⭐ | Matrix Layer Rotation | JavaScript | Hard | 80 | Math solution to the problem, O(1) if the loop to print the result isn't considered, otherwise O(m*n) |
| ⭐ | ACM ICPC Team | JavaScript | Easy | 25 | Using bitwise operations, and a custom Hamming Weight implementation to count ones, because the HackerRank's v8 version hasn't yet a BigInt implementation. Best case O(n^2) where n is the topics length |
| ⭐ | Queen's Attack II | JavaScript | Medium | 30 | Math solution to the problem, O(k), where k is the number of obstacles |
| ⭐ | Modified Kaprekar Numbers | JavaScript | Easy | 30 | Math and very performatic solution, without using Strings nor brute force, O(n), where n = q - p |
| Equalize the Array | JavaScript | Easy | 20 | O(n) | |
| ⭐ | Jumping on the Clouds | JavaScript | Easy | 20 | O(log n) |
| ⭐ | Repeated String | JavaScript | Easy | 20 | The algorithm doesn't count the string a second time, both best and worst case is O(n) where n is the length of the string |
| Lisa's Workbook | JavaScript | Easy | 25 | ||
| Bigger is Greater | JavaScript | Medium | 35 | ||
| Organizing Containers of Balls | JavaScript | Medium | 30 | ||
| The Time in Words | JavaScript | Medium | 25 | O(1) | |
| Beautiful Triplets | JavaScript | Easy | 20 | O(n) | |
| Minimum Distances | JavaScript | Easy | 20 | O(n) | |
| Halloween Sale | JavaScript | Easy | 20 | O(1) | |
| Non-Divisible Subset | JavaScript | Medium | 20 | ||
| Cut the Sticks | JavaScript | Easy | 25 | ||
| Library Fine | JavaScript | Easy | 15 | O(1) | |
| Sherlock and Squares | JavaScript | Easy | 20 | O(1) | |
| Append and Delete | JavaScript | Easy | 20 | O(min(s, t)) | |
| Extra Long Factorials | JavaScript | Medium | 20 | ||
| Service Lane | JavaScript | Easy | 20 | ||
| Chocolate Feast | JavaScript | Easy | 25 | O(1) | |
| Find Digits | JavaScript | Easy | 25 | O(n) | |
| Jumping on the Clouds: Revisited | JavaScript | Easy | 15 | O(n / k) where k is the number of jumps | |
| Sequence Equation | JavaScript | Easy | 20 | ||
| Circular Array Rotation | JavaScript | Easy | 20 | ||
| Save the Prisoner! | JavaScript | Easy | 15 | O(1) | |
| ⭐ | Viral Advertising | JavaScript | Easy | 15 | Alternative way to solve it using this integer sequence formula: https://oeis.org/A061418 |
| Beautiful Days at the Movies | JavaScript | Easy | 15 | O(n) | |
| Angry Professor | JavaScript | Easy | 20 | O(n) | |
| Utopian Tree | JavaScript | Easy | 20 | O(1) | |
| Designer PDF Viewer | JavaScript | Easy | 20 | ||
| The Hurdle Race | JavaScript | Easy | 15 | O(1) | |
| Climbing the Leaderboard | JavaScript | Medium | 20 | O(n + log(m)) | |
| Picking Numbers | JavaScript | Easy | 20 | O(1) | |
| ⭐ | Forming a Magic Square | JavaScript | Medium | 20 | Using Édouard Lucas general formula to generate all possible magic squares of order 3 |
| Cats and a Mouse | JavaScript | Easy | 15 | O(1) | |
| Eletronics Shop | JavaScript | Easy | 15 | ||
| Counting Valleys | JavaScript | Easy | 15 | O(n) | |
| Drawing Book | JavaScript | Easy | 10 | O(1) | |
| Sock Merchant | JavaScript | Easy | 10 | O(1) | |
| Bon Appétit | JavaScript | Easy | 10 | O(n) | |
| Day of the Programmer | JavaScript | Easy | 10 | O(1) | |
| Migratory Birds | JavaScript | Easy | 10 | ||
| Divisible Sum Pairs | JavaScript | Easy | 10 | ||
| Birthday Chocolate | JavaScript | Easy | 10 | ||
| Breaking the Records | JavaScript | Easy | 10 | O(n) | |
| Between Two Sets | JavaScript | Easy | 10 | Using Euclid's division algorithm for greatest common divisor | |
| Kangaroo | JavaScript | Easy | 10 | ||
| Apple and Orange | JavaScript | Easy | 10 | ||
| Grading Students | JavaScript | Easy | 10 |
Data Structures
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| Array Manipulation | JavaScript | Hard | 60 | ||
| Sparse Arrays | JavaScript | Medium | 25 | ||
| Dynamic Array | JavaScript | Easy | 15 | ||
| Array DS | JavaScript | Easy | 10 |
Constructive Algorithms
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| New Year Chaos | JavaScript | Medium | 40 |
Warmup
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| Time Conversion | JavaScript | Easy | 15 | ||
| Birthday Cake Candles | JavaScript | Easy | 10 | ||
| Mini-Max Sum | JavaScript | Easy | 10 | ||
| Staircase | JavaScript | Easy | 10 | ||
| Plus Minus | JavaScript | Easy | 10 | ||
| Diagonal Difference | JavaScript | Easy | 10 | ||
| A Very Big Sum | JavaScript | Easy | 10 | ||
| Compare the Triplets | JavaScript | Easy | 10 |
Mathematics
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| Army Game | JavaScript | Easy | 10 | ||
| Minimum Height Triangle | JavaScript | Easy | 10 | ||
| Handshake | JavaScript | Easy | 10 | ||
| Maximum Draws | JavaScript | Easy | 5 | ||
| Find the Point | JavaScript | Easy | 5 |
Interview Preparation Kit
Arrays
| Problem | Solution | Difficulty | Points | Note | |
|---|---|---|---|---|---|
| Minimun Swaps 2 | JavaScript | Medium | 40 | ||
| Arrays: Left Rotation | JavaScript | Easy | 15 | ||
| 2D Array - DS | JavaScript | Easy | 15 |