912. Sort an Array | sorting | Leetcode Daily Challenge | DSA | Hindi

preview_player
Показать описание
Problem Name:
912. Sort an Array

Problem Statement:
Given an array of integers nums, sort the array in ascending order and return it.

You must solve the problem without using any built-in functions in O(nlog(n)) time complexity and with the smallest space complexity possible.

Problem Link:

Graph Playlist:

Java Plus DSA Placement Course Playlist:

Java Plus DSA Sheet:

Notes:

Telegram Link:

Ultimate Recursion Series Playlist:

Samsung Interview Experience:

Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung

Timestamp:
0:00 - Introduction

#ShashwatTiwari #coding​​ #problemsolving​
Рекомендации по теме
Комментарии
Автор

can we use quicksort median of medians??

jay-P
Автор

Bhaiya aaj ja daily problem ka video kaha hai, I was looking forward to it

saisree
Автор

I applied quick sort but mai bhool gya worst case me n^2 ho jata hai😬

PiyushSharma-weyd
Автор

Can we apply countsort.please tell me?🎉❤

dayashankarlakhotia
Автор

nice bro, your technique solving the problem and approach of explanation is great !

suryapratapsingh
Автор

bhaiya please reply mera code bhi to same hai pr mera t.c : 373ms hai aisan kyu ache se explain kr dijiye
class Solution {
public int[] sortArray(int[] nums) {
mergesort(nums, 0, nums.length-1);
return nums;
}
public void mergesort(int nums[], int si, int ei){
if(si>=ei){
return;
}
int mid = (ei-si)/2 +si;
mergesort(nums, si, mid);
mergesort(nums, mid+1, ei);
merge(nums, si, mid, ei);
}
public void merge(int nums[], int si, int mid, int ei){
int temp[] = new int[ei-si+1];
int i = si;
int j = mid+1;
int k= 0;
while((i<=mid)&&(j<=ei)){
if(nums[i]<nums[j]){
temp[k] = nums[i];
i++;
}
else{
temp[k] = nums[j];
j++;
}
k++;
}
while(i<=mid){
temp[k++] = nums[i++];
}
while(j<=ei){
temp[k++] = nums[j++];
}
for(i= si, k=0;k<temp.length;k++, i++){
nums[i] = temp[k];
}
}

}

nileshchandra
join shbcf.ru