English
Open in Telegram

Postimport java.util.*;

12 April 2023
M
Machine Learning coder
Photo
click to show
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) arr[i]=sc.nextInt(); System.out.printf(myFun(arr)?"Yes":"No"); } public static boolean myFun(int[] arr) { int count = 0; for (int i = 1; i < arr.length; i++) { if (arr[i] < arr[i - 1]) { count++; if (count > 1) { return false; } if (i == 1 || arr[i] >= arr[i - 2]) { arr[i - 1] = arr[i]; } else { arr[i] = arr[i - 1]; } } } return true; } } #java
1 · 1.3K ·

Nearby in the feed

MMachine Learning coderAccenture Dive coding Language: pythonMMachine Learning coderAccenture Diva coding Language c++
this message
MMachine Learning coderTCS NQT RESULTMMachine Learning coderPhoto
DDeloitte | COGNIZANT | IBM | CAPGEMINIDeloitte | COGNIZANT | IBM | CAPGEMINI@python_java_Coding · channel · Tech
7 178subscribers406average post reach
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count