All Questions
24 questions
0
votes
2
answers
1k
views
Sherlock and Anagrams in Javascript
I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
3
votes
4
answers
297
views
Finding the Longest Word in a String
Challenge:
Return the length of the longest word in the provided sentence.
I've made a solution that works but it is kinda bad since the time complexity is \$O(n \log n)\$ and it involves mutation.
...
17
votes
4
answers
10k
views
Cropping a message using array splits
I am trying to write a simple function to crop a given message to a specific length but at the same time not to cut the words in between and no trailing spaces in the end.
Example:
Input String: ...
5
votes
2
answers
293
views
Count characters in a string
This code is supposed to count each character in a given string and account for error handling and type casting as well, and it should do it in the most efficient manner possible, with O(n) being an ...
6
votes
2
answers
583
views
Search and Replace (FreeCodeCamp intermediate algorithm scripting)
I completed this challenge Search and Replace and passed the tests:
Perform a search and replace on the sentence using the arguments provided and return the new sentence.
First argument is the ...
8
votes
5
answers
12k
views
Find palindromic substrings as efficiently as possible
I've written a function to calculate all the distinct substrings of a given string, that are palindromes. The string is passed as the argument to the function. For example, the string abba is a ...
6
votes
2
answers
5k
views
Partitioning input strings by even and odd indexes
I have been trying to learn javascript for a year now, and have just embarked on HackerRank's 30 days of code. After a couple of days I finally solved this problem. Here is the task (if you click the ...
1
vote
2
answers
174
views
Checking whether one string matches another
This checks whether one string has all the chars in another string to make up that exact string. Counts matter so for, for example, str1 = 'abcdgbff' str2 ='aaabb' ...
3
votes
1
answer
259
views
Trim to the nearest word under limit
Given a text and the length limit I need to trim the text to the word which is nearest to the limit.
...
8
votes
2
answers
11k
views
Get character occurence count along with character in a string
I want to find character sequence count in a given string.
Sample Input: aaaabbbbaaacccbbb
Output: a4b4a3c3b3
My below function is working great and giving me the same result. but can this be ...
5
votes
2
answers
1k
views
Checking the balanced parenthesis as asked in interview
Input:
Input contains one string S which consists of big and small latin
letters, digits, punctuation marks and brackets from the set []{}().
Constraint:
Constraints. The length of S ...
3
votes
1
answer
45
views
Get string distance for a pseudo fuzzy search
We are using the following for evaluating strings for a pseudo fuzzy search. Curious if anything sticks out as needing optimization
...
10
votes
2
answers
10k
views
A String.prototype.diff() implementation (text diff)
I just had the idea to develop an algorithm to calculate and highlight the difference between two strings. I know that there are already some libraries to do the job but I just tried to make my own. I ...
6
votes
3
answers
2k
views
Checking if string characters can be arranged to form another string
I am working on a code project that checks if all the characters in str1 can be arranged to form another string (str2). If all ...
5
votes
2
answers
1k
views
List all repeated substrings with a fixed length
While fiddling around, I've made a very simple and naive function to retrieve any repeated sub-string within a certain string.
...