Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
256 views

Time and Space Complexity of Leetcode Problem #31. Next Permutation

The question is as follows: Given a collection of distinct integers, return all possible permutations. Example: ...
ny_coder_dude's user avatar
7 votes
2 answers
6k views

Permutations with replacement in Python

Many a times, I've had the need to use a permutations with replacement function. So, I've written a function to do just that: ...
Sriv's user avatar
  • 2,800
6 votes
1 answer
655 views

Best way to performance permutations

This has been my white whale for a while, the idea is convert all the symbols to the goal symbol using all the pieces. I did an algorithm like 5 years ago (now is lost) and reach lvl 48 but got stuck ...
Juan Carlos Oropeza's user avatar
5 votes
2 answers
1k views

Finding all possible letter combinations from an inputted phone number

Prompt: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone ...
springathing's user avatar
3 votes
2 answers
2k views

Generate all combinations of length N through M

I've started learning programming and as matter of practice I've decided to make a program that will output all possible string combinations and put them in a file. I've manged to do that and it works ...
sptls's user avatar
  • 33
4 votes
1 answer
3k views

K-combination recursive algorithm implementation

Tried to implement this solution for finding n choose k. I have used recursion and this is how it goes for k as 4 and n as 6. Zero based The idea is to have array of size k keeping sequence of ...
newbie_old's user avatar
1 vote
1 answer
126 views

Count all possible attendance records with length n, which will be regarded as rewardable

Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after \$\mod 10^9 + 7\$. ...
kumarmo2's user avatar
  • 261
3 votes
2 answers
3k views

Non-Contiguous Substrings

Problem: A non-contiguous substring of string \$s\$ is a sequence of \$k \geq 0\$ characters in \$s\$, in the order in which they occur in \$s\$. For instance, the set of all non-contiguous ...
francium's user avatar
  • 139
6 votes
1 answer
4k views

Permutation algorithm of N unique elements with low memory footprint

I actually had a real life need (outside work, no less) to come up with every single permutation of N elements (the N in my case being 12, so a total of ...
amphibient's user avatar
8 votes
2 answers
4k views

Consecutive Primes challenge at CodeEval.com and memory allocation issue

I finally solved this challenge with using recursion and figured out why the automatic scorer wasn't passing my previous solutions. I was using NSMutableArray to ...
Yan's user avatar
  • 683
2 votes
1 answer
6k views

Nsum problem: find all n elements in an array whose sum equals a given value

I am pretty new to Python, so I want to listen to any advice that improve my coding style in a "pythonic" way, even about naming style of variables. The following code reflects a very general paradigm ...
Fashandge's user avatar
  • 123
4 votes
1 answer
2k views

Seeking improved Objective-C permutation algorithm

This algorithm seeks to find all of the possible permutations of a word: ...
arc4randall's user avatar
8 votes
1 answer
2k views

Speeding up subset sum implementation

Important fact: the number of the input is greater than 1. How do I use this fact to speed up this solution? ...
user3527406's user avatar
6 votes
2 answers
4k views

Permutation of given string

I am reading a book on DSA, and the author explains how to generate the permutation of strings using recursion. I want to know if there are better ways of doing the same, unless this is the best ...
luckysing_noobster's user avatar