1389 Create Target Array in the Given Order | Zero to FAANG Kunal | Assignment Solution | Leetcode

  Рет қаралды 9,088

Programmers Zone

Programmers Zone

Күн бұрын

Пікірлер: 33
@spencer9752
@spencer9752 3 жыл бұрын
Nice solution bro , everyone is using arraylist/vector which makes the zero logic but you explained the best approach without using extra space ❤️
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
Thanks and welcome :)
@RaymaxOfficial
@RaymaxOfficial 3 жыл бұрын
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.
@RaymaxOfficial
@RaymaxOfficial 3 жыл бұрын
KEEP UPLOADING !! SO IN NEED.
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
@@RaymaxOfficial thanks a lot I'll :)
@sainayan
@sainayan 3 ай бұрын
Not a good solution but a unique one.
@arabindrajak4951
@arabindrajak4951 2 жыл бұрын
Thankyou brother samagh aa gya achi tarah se🥰
@ProgrammersZone
@ProgrammersZone 2 жыл бұрын
Welcome buddy
@RaymaxOfficial
@RaymaxOfficial 3 жыл бұрын
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 ?
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
Time Complexity : O(n) Space Complexity : O(n)
@RaymaxOfficial
@RaymaxOfficial 3 жыл бұрын
@@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?
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
We'll have to consider so after considering that time complexity becomes O(n^2)
@RaymaxOfficial
@RaymaxOfficial 3 жыл бұрын
@@ProgrammersZone Thankyou so much sir for clarifying!!
@AdityaSharma-fd9px
@AdityaSharma-fd9px 3 жыл бұрын
@@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
@shashanksharma7747
@shashanksharma7747 3 жыл бұрын
Good Solution too many approach keep uploading the videos
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
For sure :)
@anshumanbehera3706
@anshumanbehera3706 3 жыл бұрын
thanks bro its help me a lot
@laugh_till_u_pee968
@laugh_till_u_pee968 3 жыл бұрын
keep uploading.
@ProgrammersZone
@ProgrammersZone 3 жыл бұрын
Thanks a lot Keep Supporting :)
@abhinavkumar2085
@abhinavkumar2085 2 жыл бұрын
Good
@ProgrammersZone
@ProgrammersZone 2 жыл бұрын
Thank you
@hailex2045
@hailex2045 2 жыл бұрын
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...
@ProgrammersZone
@ProgrammersZone 2 жыл бұрын
Buddy don't focus on leetcode's analysis instead just focus on time and space complexity it will make far more sense :)
@hailex2045
@hailex2045 2 жыл бұрын
@@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
@ayushacharya4778 Жыл бұрын
is this the best solution?? time complexity kam nahi hosakta ??
@sukiratsingh985
@sukiratsingh985 8 ай бұрын
Ho sakti hai bhai nlogn mai kiya hai kisi ne uska thoda complex tha
@evelynsummer4020
@evelynsummer4020 2 жыл бұрын
Can you explain in English please i don't understand
@anikethpaul3657
@anikethpaul3657 2 жыл бұрын
bhai ek solution dunga...agar channel grow karna hain toh thoda kam minutes ka vid banao
@ProgrammersZone
@ProgrammersZone 2 жыл бұрын
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 :)
@abhishekkr8077
@abhishekkr8077 Жыл бұрын
@@ProgrammersZone you are best bro
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 60 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 21 МЛН
Turing's Live Coding Challenge | Node.JS Mock Interview
35:36
BS-9. Find Peak Element
32:53
take U forward
Рет қаралды 206 М.
ArrayList In Java + Notes | Java Placement Course
17:13
Apna College
Рет қаралды 694 М.
Dynamic Memory Allocation | C Programming Tutorial
31:51
Portfolio Courses
Рет қаралды 94 М.
MUST KNOW junior role JAVA interview questions
42:15
Keep On Coding
Рет қаралды 135 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19