# Permutation – Live Coding Example – Java Interview

May 8, 2019
14 Comments

This is a live-coding session for a basic permutation problem. The code is not prepared in advance, so it should help to illustrate the thought process behind developing and testing a solution to this common computer-science algorithm.

You can find a written version of this on my blog here:

Tags: algorithm, coding, Interview, java, java tips for competitive programming, LIVE, live coding, permutation, permute
wow this is the first video that makes sense to me! Thanks!

This Function fails in case of Duplicate Elements.. prints out duplicate AABC –> 18 permutations but should have result in 12 combinations only. I can easily filter that using set but that decreases the efficiency of algorithm.

I would safe guard against the length of the string being passed with this recursive implementation.

This is a really good video. Things are cleared by steps. Thanks!

Hi John H, for private help how do I reach you. possible to share with me the email address so that I cam mail you kindly.

What keyboard do you use in this video ?

Hi John, Thank You very much for the tutorial.

I have just one question:

how do I create permutations of 3,

BUT WITHOUT repetitions?

example:

123 would normally give permutations of

(132, 213, 231 321, 312)

So, how do I then only have permutations of ONLY 123???

(since the rest are sort of REPEATS of the same thing)

thank you in Advance for your answer.

Tafara

Great . Awesome explanation , much helpful than the other videos i found on the internet .:)

Can you also mention runtime and space complexity which will make this tutorial great…

Awesome solution.easily able to grab it

Great solution, easiest to understand I found so far.

This is perfect. I think it's rarely to see someone present their code like they are in the actual interview like you said in the beginning. Thanks a lot!

Very short code compared to those I found on internet. Gee thanks!

Great Explanation!