All Questions
226
questions
3
votes
0
answers
56
views
Number of ways to complete a plan
I worked on a dynamic programming problem. Here is its link. I have to find the number of ways respecting the constraint that user doesn't go to the Gym for two consecutive days.
...
3
votes
3
answers
6k
views
Foobar Fuel Injection Perfection efficiency
I was writing this code and was using the BigInteger class because it needs to work with numbers up to 309 digits long, however it takes too long to run with numbers that are too big. I was hoping to ...
6
votes
2
answers
4k
views
Generating the Cartesian product of N-arrays
I have written this Java snippet to generate all permutations of a given Array of a HashMap. Can this be done in a better way? ...
3
votes
2
answers
2k
views
Java Left Rotate Array upto n times
Java problem to left rotate an array upto n times. It would be nice if anyone can review this code.
Task:
A left rotation operation on an array of size shifts each of the array's elements unit to ...
4
votes
1
answer
394
views
HackerRank week of code 32 competition: GeometrickTrick
last week I entered HackerRank Week of Code 32, a week-long competition, with 6 coding challenges, ranging from easy to hard. I am satisfied with my result at this particular competition but I also ...
4
votes
2
answers
634
views
Find lexicographical permutations
I have tried many possible methods here but I am still not able to reduce the time complexity of below algorithm.
The basic layout of my problem is as follows:
I have a string that is composed of ...
0
votes
1
answer
431
views
Produce the nth lexicographic permutation of a string consisting of letters H and V
I have tried many possible methods here but I am still not able to reduce the time complexity of below algorithm.
...
3
votes
2
answers
289
views
Shuffling chunks of ints in an array
The shuffle method in ShuffleMethods.java takes an array of ints and shuffles them by chunks of ints in another array. So for example, if we had an array of ints ...
5
votes
1
answer
736
views
Sequence Alignment of two Strings
I have some code which aligns the sequence of two strings, I am doing numbers just for my implementation.
I was wondering whether there are any performance enhancements I could make as the code ...
7
votes
1
answer
9k
views
Reversing second half of linked list
I recently had an interview where I was asked to reverse the second half of a linked list. The driver program was unknown to me, I just needed to write the method to do this. The method was supposed ...
1
vote
3
answers
2k
views
Dijkstra implementation for maze solving that works fine and returns shortest path
I would like to make my code "prettier" and also speed up the runtime of my implementation.
Nodeinfo is literally just an object that holds its "parent node"(the node it came from) and its distance. i ...
4
votes
1
answer
105
views
Bezier evaluation in O(n)
The really stupid way to evaluate bezier curves is with recursion, which is \$O(2^n)\$, which can be lowered to \$O(n^2)\$ with memoization. De Casteljau's algorithm improves on this, and is still \$O(...
3
votes
1
answer
108
views
Given two words, transform the first one into the second [closed]
As the title says, the problem I had to do sounded something like this:
We are given two words, S1 and S2. We must transform S1 into S2, using the following operations:
insert: insert a character in ...
3
votes
1
answer
2k
views
Ashton and String Hackerrank
Online coding challenge Hacker Rank.
I tried to solve it using the naive appraoch first but its failing on some of the inputs and rest its getting timed out. How to get started in problem like these ...
2
votes
1
answer
4k
views
Build String Hackerrank
Online challenge on Hacker Rank.
Please follow the description from the above link.
...