All Questions
34 questions
4
votes
7
answers
279
views
Breaking a string expression in operator and operands
Requesting for a code review for a scala implementation.
Problem
Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
2
votes
3
answers
124
views
Is My Function to Find Triplets in Scala running in O(N^2)
Given the classical problem to find triplets that sum to zero in an array. Is my Scala implementation correct and executed in O(N^2)? If yes, why? Can someone make a running time analysis.
What other ...
1
vote
1
answer
123
views
Scala graph coloring
i have solved this problem https://leetcode.com/problems/find-eventual-safe-states/submissions/
...
2
votes
0
answers
391
views
Bellman-Ford Implementation in Scala/Java
I think the part to get shortest path from the cost table got pretty messy. Also can use some tips on how to avoid the extra O(V+E) work checking all edges from source to dest after getting the cost ...
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 ...
0
votes
1
answer
531
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:
...
1
vote
1
answer
180
views
Finding the number of inversions in an Array
I am doing a college assignment where I have to count the number of inversions in an array/list. An inversion is defined as a tuple where i<j and a[i]>a[j]. ...
1
vote
1
answer
501
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
2
answers
296
views
Using a radix tree to find case-insensitive matches in large files
I'm using a radix tree library to find case-insensitive matches from several relatively large files (~24 files each on the order ~150MB).
My current algorithm requires me to read the chars of an ...
2
votes
1
answer
485
views
HackerRank Equal with Scala
For studying Scala, I wrote some code to solve the Equal problem on HackerRank. But I am stuck on test case #15 due to timeout.
Christy is interning at HackerRank. One day she has to distribute some
...
0
votes
1
answer
2k
views
Re-inventing the wheel: Binary search in Scala
I am trying to implement the code described in this post about how Reddit uses binary search to identify duplicate user names, in Scala. Just to clarify, this is mainly for me figuring out how these ...
8
votes
1
answer
351
views
Sieve of Eratosthenes performance; Scala very slow compared to Node.js
I am new to Scala so it might show. I am learning it for one of my classes and have to write a performance benchmark. I have written the Sieve of Eratosthenes in both Node.js and Scala, and my Node.js ...
0
votes
1
answer
646
views
Sort Stack using just an additional stack
The problem is from the cracking coding Interview programming book.
The problem is that:
Sort Stack: Write a program to sort a stack such that the smallest
items are on the top. You can use an ...
4
votes
1
answer
2k
views
Merge sort in one Single Function in Scala
I have implemented a sortmerge in Scala in one single function. I would like to have it reviewed, so that I can have it well organized, and it is then doing what ...
2
votes
2
answers
614
views
A Scala Maze Generator in Functional Style
I'm wondering if there is more I can do to incorporate more idiomatic scala and functional programming principles. I know the maze itself is mutable but i didn't see an easy solution to making it ...