Nice solution bro , everyone is using arraylist/vector which makes the zero logic but you explained the best approach without using extra space ❤️
@ProgrammersZone3 жыл бұрын
Thanks and welcome :)
@RaymaxOfficial3 жыл бұрын
Bro All i can say is that you are doing AWESOME JOB. TRULY CAN'T FIND A TUTORIAL OTHER THEN YOU A WHERE I AM LEARNING MULTIPLE APPROACHES TO SOLVE THE PARTICULAR QUESTION. FROM NON OPTIMIZED WAY TO OPTIMIZED WAY.
@RaymaxOfficial3 жыл бұрын
KEEP UPLOADING !! SO IN NEED.
@ProgrammersZone3 жыл бұрын
@@RaymaxOfficial thanks a lot I'll :)
@sainayan3 ай бұрын
Not a good solution but a unique one.
@arabindrajak49512 жыл бұрын
Thankyou brother samagh aa gya achi tarah se🥰
@ProgrammersZone2 жыл бұрын
Welcome buddy
@RaymaxOfficial3 жыл бұрын
I want to add this approach also, In This approach it uses ArrayList, to built the target array. ArrayList add function has an built in code where there it shifts the elements when you try to insert another element. public int[] createTargetArray(int[] nums, int[] index) { // 1. create the arraylist ArrayList a = new ArrayList(); // 2. Add elements in arraylst using add function for (int i = 0; i < nums.length ; i++) { a.add(index[i], nums[i]); } // 3. Because ArrayList has an built in function of shifting elements, that is why all we need to do is just copy the elements to our output array, because we need to return the ArrayList. int output[] = new int[nums.length]; for (int i = 0; i < nums.length ; i++) { output[i] = a.get(i); } return output; } ------------------------------------------------------------------------------------------- One question i have what is the time and space complexity here ?
@ProgrammersZone3 жыл бұрын
Time Complexity : O(n) Space Complexity : O(n)
@RaymaxOfficial3 жыл бұрын
@@ProgrammersZone Sir, Should we also consider the internal for loop arraylist is using for shifting elements or not ? if so then the time complexity will be different?
@ProgrammersZone3 жыл бұрын
We'll have to consider so after considering that time complexity becomes O(n^2)
@RaymaxOfficial3 жыл бұрын
@@ProgrammersZone Thankyou so much sir for clarifying!!
@AdityaSharma-fd9px3 жыл бұрын
@@ProgrammersZone sir i have a question why can't we simply return the a arraylist why are we making another arraylist and adding the same element in it
@shashanksharma77473 жыл бұрын
Good Solution too many approach keep uploading the videos
@ProgrammersZone3 жыл бұрын
For sure :)
@anshumanbehera37063 жыл бұрын
thanks bro its help me a lot
@laugh_till_u_pee9683 жыл бұрын
keep uploading.
@ProgrammersZone3 жыл бұрын
Thanks a lot Keep Supporting :)
@abhinavkumar20852 жыл бұрын
Good
@ProgrammersZone2 жыл бұрын
Thank you
@hailex20452 жыл бұрын
Bro he gave the solution almost a year ago by his logic which is only faster than 44% of the population whereas you can only apply Arraylist which is the simplest solution & as of now is faster than 77% of population...
@ProgrammersZone2 жыл бұрын
Buddy don't focus on leetcode's analysis instead just focus on time and space complexity it will make far more sense :)
@hailex20452 жыл бұрын
@@ProgrammersZone sure, I am planning soon to watch Kunal's video on Time Complexity but how come leetcode's analysis be wrong as it just compares your code's time complexity with others code's one.
@ayushacharya4778 Жыл бұрын
is this the best solution?? time complexity kam nahi hosakta ??
@sukiratsingh9858 ай бұрын
Ho sakti hai bhai nlogn mai kiya hai kisi ne uska thoda complex tha
@evelynsummer40202 жыл бұрын
Can you explain in English please i don't understand
@anikethpaul36572 жыл бұрын
bhai ek solution dunga...agar channel grow karna hain toh thoda kam minutes ka vid banao
@ProgrammersZone2 жыл бұрын
Bhai jisko jaisa padhna hai wo waisa dekh le according to time stamps, agar 10 min ka video banana hai to itna time question samjhane me lag jaata hai Hope you understand :)