All Questions
19 questions
5
votes
4
answers
2k
views
C#: Repeated String
From HackerRank "Repeated String" challenge:
Lilah has a string, \$s\$, of lowercase English letters that she repeated
infinitely many times.
Given an integer, \$n\$, find and print the ...
4
votes
1
answer
182
views
LeetCode: Find And Replace in String C#
It took me a while to solve this question and there are corner cases i missed hence the 4 unit tests.
please review for performance. and if you can treat this as a review for a 45 mins programming ...
2
votes
1
answer
841
views
LeetCode: Greatest Common Divisor of Strings C#
https://leetcode.com/problems/greatest-common-divisor-of-strings/
For strings S and T, we say "T divides S" if and only if S = T + ... +
T (T concatenated with itself 1 or more times)
Return ...
6
votes
3
answers
2k
views
LeetCode: Group Anagrams C#
LeetCode: Group Anagrams C#
Given an array of strings, group anagrams together.
...
2
votes
3
answers
367
views
LeetCode:implement strstr C#
https://leetcode.com/problems/implement-strstr/
I implemented Rabin-Karp algorithm
https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm
please review for performance, also if you were in an ...
3
votes
1
answer
124
views
CareerCup (Bloomberg): Check if string is valid based on brackets
The goal of this problem is to determine if a string with brackets is valid. Below is a summary of the question from careercup.
Check if string s is valid based on brackets
...
8
votes
4
answers
4k
views
Reversing a string - two approaches
Test Case:
Input- "I'm hungry!"
Output- "!yrgnuh m'I"
Approach 1: In this approach, I used a empty string and bind it with the input string reversely.
...
2
votes
1
answer
498
views
LeetCode #28 - Boyer Moore string matching algorithm
The following code implements the Boyer Moore string matching algorithm. The algorithm is used to find a sub-string (called the pattern) in a string (called the text) and return the index of the ...
3
votes
3
answers
2k
views
Interleaving two strings
The challenge:
From: URI Online Judge
Implement a program Combiner that takes two Strings as parameters and combines them, alternating letters, starting with the first letter of the first String, ...
5
votes
2
answers
23k
views
LINQ and string.Split do it yourself practice
Problem Statement:
Implement a sentence scanning functionality to parse the sentence and return a string to concatenate each word with its number of occurrences, sorted by the number of ...
4
votes
1
answer
614
views
Leetcode 125. Valid Palindrome
Problem statement
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a ...
3
votes
0
answers
791
views
Hackerrank: Sherlock and anagram (optimal time complexity)
Problem statement
Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains \$T\$, the number of testcases. Each testcase ...
19
votes
9
answers
2k
views
Repeatedly eliminate a substring
I'm trying to pass a programming challenge where we are to replace all instances of a substring in a string until there are none left. So an input like
...
2
votes
2
answers
2k
views
Leetcode 49: Group Anagrams - Hash function design talk
problem statement
Given an array of strings, group anagrams together.
For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
...
5
votes
1
answer
2k
views
Hackerrank: Sherlock and anagram
Problem statement
Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains \$T\$, the number of testcases. Each testcase ...