Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

replace elements with greatest element on right side

public class Solution 
{
    public int[] ReplaceElements(int[] arr)
    {
        int rightMax=-1;
        for(int i=arr.Length-1;i>=0;i--)
        {
           	int newMax=Math.Max(rightMax,arr[i]);
            arr[i]=rightMax;
            rightMax=newMax;
        }
        return arr;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: weighted random c# 
Csharp :: function in Razor Pages 
Csharp :: open folder dialog c# 
Csharp :: new line console c# 
Csharp :: VLC .net 
Csharp :: httppostedfilebase in .net core 3.1 
Csharp :: c# compile code at runtime 
Csharp :: placeholder syntax c# 
Csharp :: c# write byte[] to stream 
Csharp :: c# to binary 
Csharp :: .net Core Get File Request 
Csharp :: add object to list c# 
Csharp :: convert iformfile to byte array c# 
Csharp :: c# string to variable name 
Csharp :: get current playing animation of animator unity 
Csharp :: c# remove duplicates from datatable 
Csharp :: instantiate list c# 
Csharp :: xamarin hide back button 
Csharp :: c# environment variables 
Csharp :: how to set unique constraint from EF core 
Csharp :: c# string remove 
Csharp :: difference two list c# 
Csharp :: get type of variable c# 
Csharp :: get device connected to player input unity 
Csharp :: how to see image from website in wpf 
Csharp :: unity how to set rigidbody velocity 
Csharp :: how to make colliders collide with some things but not other in unity 
Csharp :: how to add item in list at first position c# 
Csharp :: CS0101 Unity Error Code 
Csharp :: item switch unity 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =