All Questions
9 questions
3
votes
1
answer
126
views
Segmentation of list to minimize the largest sum
I have written the following code for diving a list 'seq' into 'k' segments such that the maximum sum of each segment is minimized. I have used dynamic programming to solve this problem. But my class &...
3
votes
1
answer
853
views
Divide array into three disjoint sets with equal sum
Problem definition : Array partition problem
Given an array of positive integers, divide it into three disjoint subsets having equal sum. These disjoint sets cover the complete array.
Example
Input: [...
5
votes
1
answer
352
views
Total number of non overlapping subsets
I am trying to solve this question. The essence of the problem is this:
Given a list of school classes with start and end times, find the total number of non-overlapping subsets.
I've written up a ...
3
votes
2
answers
649
views
Determine if a string is a sequence of dictionary words
This is Leetcode problem 139: "Wordbreak"
Problem: Given a non-empty string s and a dictionary wordDict
containing a list ...
2
votes
1
answer
87
views
Length of the longest common sub sequence bottom up
Could I get some feedback on this code? I included a test case as well.
This code computes the longest common sub sequence given paired data, it was not part of any challenge I just did it to learn ...
1
vote
3
answers
1k
views
Subarray Sum Equals K
I've written a solution to the following leetcode problem:
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example ...
6
votes
3
answers
2k
views
Performance of dynamic Fibonacci generator and dead rabbits
I would like to improve my code style and its efficiency.
I'm just moving beyond the standard recursive approach to a lot of simple algorithms.
This post has two code snippets with slightly ...
6
votes
1
answer
3k
views
Longest common subsequence length and backtracking the string
Problem: Given two sequences, print the longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, “...
1
vote
1
answer
322
views
Find the minimum number of operations to convert 1 into n, and print the sequence of numbers
Here is my solution for the following task: Given an integer n, print the minimum number of operations needed to obtain the number n starting from the number 1, and the sequence of numbers towards the ...