Print Permutations of an array with duplicate elements

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Given an array with duplicate elements. Print all the unique permutations of elements of the array. In part-1 of this problem we discussed the solution where there are no duplicates in the array.
    Part-1: • Print Permutations of ...
    Covers Following Leetcode Problems:
    46. leetcode.com/p...
    47. leetcode.com/p...
    -----------------------------------------------------
    Join our 30-days online course to prepare for coding interviews of companies like Google, Amazon, Facebook, Microsoft, etc.
    Course On Coding: www.ritambhara....
    Course On System Design: www.ritambhara....
    We have our office in Greater Noida (India) where we run courses for students to prepare them for placements in Top IT companies. For Placement Preparation and Industrial Training call us.
    Call: +91-8377803450
    Email: krawat@ritambhara.in
    Call us to conduct a workshop in your college campus.
    Buy our books and prepare for coding interviews on your own.
    www.amazon.in/...
    For detailed discussions on Interview Questions visit:
    www.ritambhara.in/

Komentáře • 17

  • @MarkDSouza46
    @MarkDSouza46 Před 2 lety +2

    Clear and Concise. Amazing video!

  • @prateekrajput2646
    @prateekrajput2646 Před 3 lety

    loved it sir!
    hash map solution is so easy

  • @ethanjiang7070
    @ethanjiang7070 Před rokem

    great explanation

  • @raghavkumar2867
    @raghavkumar2867 Před 2 lety +1

    7:40 The video starts here

  • @bijayamanandhar3890
    @bijayamanandhar3890 Před 2 lety

    Thank you

  • @jayantmishra6966
    @jayantmishra6966 Před 2 lety

    BRILLIANT

  • @AyushGupta-be1ij
    @AyushGupta-be1ij Před 3 lety

    well explained!!

  • @michaelgyawu7929
    @michaelgyawu7929 Před 2 lety +2

    Nice video. However, I still haven't understood which part of the logic prevent the printing 122, 122. 1 is the only non-repeating element. But after fixing that 1 you are left with the subset {2,2} and this subset is then permuted. Shouldn't there be a condition/contrain on that subset to prevent the same permutation being printed twice?.
    Your logic, to my understanding, only goes to show how to avoid fixing a duplicate element in a given set more than once. Hence compressing the output: 212, 221 and 221,212 into just 212 and 221.

  • @mrinaldas2863
    @mrinaldas2863 Před 2 lety

    Sir how to show 100 ^ 50 permutation list,plz answer me

  • @KishoreKumar-pf8ku
    @KishoreKumar-pf8ku Před 3 lety

    what's the space complexity of this approach? Will it be O(N) or O(N*N) as the recursion goes deep till n and at each level we could have a HashSet of size N.

  • @dipikakale8232
    @dipikakale8232 Před 2 lety

    Getting wrong answer
    public class Solution {
    ArrayList ans = new ArrayList();
    public int[][] permute(int[] A) {
    ArrayList a = new ArrayList();
    for(int i=0; i 0)
    cols = ans.get(0).size();
    int[][] r = new int[rows][cols];
    for(int i=0; i

  • @lifetraveler8008
    @lifetraveler8008 Před 2 lety

    Thank you