CodingHuman #Coding_Help , All exam codes, Coding solutions, accenture TCS Wipro Nagarro Persistent Cisco
588 subscribers
136 photos
310 links
We Provide free material, Coding stuff, Placement material, Handwritten Notes, previous year company questions, Job updates and many more.
Conding help.
Download Telegram
We are going to start and sharing the DSA Important questions with solutions!!! โœ…โœ…โœ…โœ…
Next permutation in c#(Leetcode, Optimal one)

public void NextPermutation(int[] nums) {

int ind = -1;
int n = nums.Length;
@Coding_human
for(int i=n-2; i>=0; i--)
{
if(nums[i]<nums[i+1])
{
ind =i;
break;
}
}
if(ind==-1)
{
Array.Reverse(nums,0,n);
return;
}
for(int i=n-1; i>ind; i--)
{
if(nums[i]>nums[ind])
{
int swap=0;
swap = nums[i];
nums[i]=nums[ind];
nums[ind]=swap;
break;
}
}



Array.Reverse(nums,0+ind+1,nums.Length-1-ind);

@Coding_human
If you have any doubts feel free to leave a comment , we will get back to you.
*FLIPKART BIG BILLIONS DAYS + Amazon great indian festival*

https://t.me/DMAD_Discussion

MUST JOIN FOR LOOOT DEALS ๐Ÿ”ฅ
Be active at 12AM for loot deals
Diwali biggest sale

https://t.me/DMAD_Discussion

24/7 deals will be posted here only. ๐Ÿค