// Online Java Compiler // Use this editor to write, compile and run your Java code online class HelloWorld { public static void main(String[] args) { int arr[]={0,1,0,2,1,0,1,3,2,1,2,1}; int left[]=new int[arr.length]; int right[]=new int[arr.length]; int leftmax=0; for(int i=0;i<arr.length;i++){ leftmax=Math.max(arr[i],leftmax); left[i]=leftmax; } int rightmax=0; for(int i=arr.length-1;i>=0;i--){ rightmax=Math.max(arr[i],rightmax); right[i]=rightmax; } int water=0; for(int i=0;i<arr.length;i++){ int min=Math.min(left[i],right[i]); water+=(min-arr[i]); } System.out.println(water); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int R = sc.nextInt(); int sum = 0; int income[] = new int[N]; int outcome[] = new int[M]; for(int i = 0; i < N; i++) income[i] = sc.nextInt(); for(int i = 0; i < M; i++) outcome[i] = sc.nextInt(); for(int i = 0; i < M; i++) sum += (outcome[i] - R); for(int i = 0; i < N; i++) sum -= (income[i] - R); if(sum == 0) System.out.println("Balanced"); else System.out.println(sum - R); } }
Jo 2 Coding Questions ke liye 90 Min milte hai ,usme humlog kabhi bhi unn 2 Questions ke beech switch kar sakte hai ki ?? Har 1 Coding Question ka time slot fixed hota hai aur agar fixed hota hai to 1st quesn ko kitna time milta hai ??
PYTHON CODE WHERE I HAVENT USED OPERATORS count=0 n=int(input("enter a range that u want to check magic no")) for j in range(1,n+1): binlist=list(bin(j)[2:]) print(binlist) for i in range(len(binlist)): if int(binlist[i])==0: binlist[i]=1 else: binlist[i]=2 print(binlist) su = sum(int(x) for x in binlist) if su%2!=0: count=count+1 print(count)
Hi sir I have joined in one company as a graduate appreticeship trainee before getting tcs OL. If I want to abscond from this company, will tcs bgc fail. I do not have pf and I have 30 das notice. I attendes tcs as fresher. I received only stipend from current campany and I try to abscond as they are not giving me the releiving letter. Will.I be caught in tcs bgc if I hide this company? Pls answer sir
Hi sir I have joined in one company as a graduate appreticeship trainee before getting tcs OL. If I want to abscond from this company, will tcs bgc fail. I do not have pf and I have 30 das notice. I attendes tcs as fresher. I received only stipend from current campany and I try to abscond as they are not giving me the releiving letter. Will.I be caught in tcs bgc if I hide this company? Pls answer sir
public class Find_number_of_cards_pyramid { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter Number of levels of Pyramid"); int levels = sc.nextInt(); int count =0; for(int i=1;i<=levels;i++){ count = count+2*i; } System.out.println(count); } }
Sir, I have applied for Packaged APP Development Associate in accenture. I received assesment slot booking mail on 20th August, but it was showing "No slots available at the moment. Comeback later!". Will I get another mail regarding slots booking.? Will I able to proceed further in the hiring process.
2nd question: import java.util.*; public class Main { 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(); } ArrayList<Integer> list=new ArrayList<Integer>(); for(int i=0;i<n;i++){ if(arr[i]>=0) list.add(arr[i]); } System.out.println(list); // if you want to see the positve element list. if(list.size()%2 != 0){ System.out.println(list.get(list.size()/2)); } else System.out.println(list.get((list.size()/2)-1)); } }
does this code satisfies for above question conditions:? import java.io.*; import java.util.*; public class Subarray { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.err.println("enter the length of array:"); int n=in.nextInt(); int a[]=new int[n]; System.err.println("enter the array values:"); for(int i=0;i<a.length;i++) { a[i]=in.nextInt(); } int res=Subarray(a); System.err.println(res); } static int Subarray(int a[]) { int zeroscount=0; int onescount=0; for(int i=0;i<a.length;i++) { if(a[i]==0) zeroscount++; else onescount++; } if(zeroscount<onescount) return (zeroscount+zeroscount); else return (onescount+onescount); } }