Impressing the Boss

Sort by

recency

|

59 Discussions

|

  • + 0 comments

    I iterate through the sales data array and check if there exists any consecutive pair of years where the sales decrease. If I find such a pair, I have tried modifying one of the elements to make the sales increase. If there are more than one such pairs or if modifying any of the elements does not result in increasing sales, then it is not possible to present the annual sales graph as required

  • + 0 comments
    static String canModify(int[] a) {
            /*
             * Write your code here.
             */
            int [] temp = a.clone();
            for(int i = 1; i<a.length; i++){
                if(a[i]<a[i-1]){
                    temp[i-1]=a[i];
                    a[i] = a[i-1];
                    break;
                }
            }
            int x = 0;
            int y = 0;
            for(int i = 0; i<a.length-1; i++){
                if(a[i]>a[i+1])
                    x++;
                if(temp[i]>temp[i+1])
                    y++;
                
            }
          return x==0 || y==0 ? "YES":"NO";
    
        }
    
  • + 0 comments

    CAN SOMEONE CORRECT IT import java.io.; import java.math.; import java.text.; import java.util.; import java.util.regex.*;

    public class Solution {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        while(t>0)
        {
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
            {
                a[i]=sc.nextInt();
    
            }
            if(n==1)
            {
                System.out.println("YES");
            }
            else
            {
            int l=0,c=0;
            for(int i=0;i<n-1;i++)
            {
                if(a[i]>a[i+1])
                {
                    l++;
                }
                else
                {
                 c++;
                }
            }
            if(l==0||l==1)
            {
               System.out.println("YES");
            }
            if(l>1)
            {
                System.out.println("NO");
            }
            }
            t--;
        }
            }
    

    }

  • + 0 comments

    my code code worked for many custom test cases . suggestions if any is appreciated

    include

    include

    using namespace std; int main(){ int row,count1=0,max1=0; cin>>row; vector> myvector(row); for(int i=0;i>col; myvector[i]=vector (col); for(int j=0;j>myvector[i][j]; }

    }
    for(int i=0;i<myvector.size();i++){
        for(int j=0;j<myvector[i].size()-1;j++){
            if(myvector[i][j]>myvector[i][j+1] || myvector[i][j+1]<max1 ){
                max1=myvector[i][j];
                count1++;
            }
        }
        if(count1>1)
        cout<<"NO\n";
    else
        cout<<"YES\n";
    }
    

    }

  • + 0 comments

    hi anyone post the solution in java..