Skip to main content

All 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 ...
leonheess's user avatar
  • 161
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. ...
DreamVision2017's user avatar
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: ...
beNerd's user avatar
  • 271
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 ...
Brian Ruff's user avatar
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 ...
Leda Erlandson's user avatar
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 ...
Matt Kent's user avatar
  • 217
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 ...
Dream_Cap's user avatar
  • 641
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' ...
uxvikas's user avatar
  • 23
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. ...
CodeYogi's user avatar
  • 5,137
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 ...
Mr.7's user avatar
  • 233
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 ...
CodeYogi's user avatar
  • 5,137
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 ...
John A Curtis's user avatar
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 ...
Redu's user avatar
  • 926
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 ...
dpg5000's user avatar
  • 163
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. ...
Ismael Miguel's user avatar

15 30 50 per page