All Questions
12 questions
3
votes
1
answer
72
views
Scala: Cumulative String Tokenisation
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below,
...
1
vote
2
answers
337
views
Count Substrings for a binary string
Problem is taken from leet code.
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings ...
2
votes
0
answers
319
views
KMP algorithm in scala
I implemented KMP pattern matching algorithm in Scala. My code works but it looks more imperative and a scala translation of C/C++ implementation.
I am not able to figure out how to manage multiple ...
1
vote
1
answer
124
views
Find first repeating Char in String
Given a string, find the first repeating character in it.
Examples:
firstUnique("Vikrant") → None
...
0
votes
1
answer
534
views
Print words in decreasing order of frequency in Scala
Given a string print its words in decreasing order of frequency.
Example:
i/p - "aa bbb ccc aa ddd aa ccc"
o/p - aa,ccc,ddd,bbb
Scala:
...
0
votes
1
answer
391
views
find if one string is a valid anagram of another , in scala
Question is taken from leet code.
Problem
Given two strings s and t , write a function to determine if t is an anagram of s.
Examples
...
4
votes
1
answer
931
views
Longest Substring Without Repeating Characters in Scala
Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
1
vote
1
answer
503
views
Check Is Anagram Scala HashMap based implementation
Here is the HashMap based implementation of the function checking whether two strings are anagrams:
Example:
...
4
votes
3
answers
145
views
Compare ZIP codes, disregarding leading zeros
I have a function that compares ZIP codes. It also has to handle cases where the input ZIP code be missing leading zeros, have extraneous leading zeros. This is what I've come up with. I don't have ...
1
vote
2
answers
235
views
Find the most frequent character in a string
I'm trying to solve this problem https://community.topcoder.com/stat?c=problem_statement&pm=40
Given a string made up of ONLY letters and
digits, determine which character is repeated the ...
7
votes
3
answers
6k
views
Checking for balanced parentheses
I wrote a method to check if each parenthesis in a string is closed. It should take into account the order in which a parenthesis is presented, e.g. "hello)goodbye(" should return false even though ...
6
votes
3
answers
3k
views
A safer way to cut a string
I want to get just the first line of a big string. Currently, here's how I do it:
...