content
stringlengths
219
31.2k
complexity
stringclasses
5 values
file_name
stringlengths
6
9
complexity_ranked
float64
0.1
0.9
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); m = 0; long sum = 0; int[] expon = new int[n]; for (int i = 0; i < n; i++) { expon[i] = s.ne...
n_square
609.java
0.9
// Java program to Count elements which // divides all numbers in range L-R import java.io.*; class GFG { // function to count element // Time complexity O(n^2) worst case static int answerQuery( int a[], int n, int l, int r) { // answer for query int count = 0 ; // 0 based index l = l - 1 ; ...
n_square
61.java
0.9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; import java.util.StringTokenizer; public class main { static class Interval{ int start; int end; public Interv...
n_square
613.java
0.9
import java.util.ArrayList; import java.util.Scanner; public class TaxiDriversAndLyft { static class Resident{ Integer index; // For all residents Integer type; // 1 if driver & 0 for rider Integer requests; // Only for drivers public Resident(int index, int type) { this.index = index; this.t...
n_square
623.java
0.9
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Lyft { private static FastScanner scan = new FastScanner(System.in); private static PrintWriter pr = new PrintWriter(System.out); private static int n, m, taxistNumber, noTaxistNumber = 0; static people peoples[]...
n_square
624.java
0.9
import java.util.Scanner; public class TaxistsnLyft { public static void main (String[] args){ Scanner scan = new Scanner (System.in); int n = scan.nextInt(); int m = scan.nextInt(); int k = n+m; long[] arr1 = new long[k]; for(int i = 0; i<k; i++){ arr1[i]=scan.nextLong(); } long[] tax = new long[...
n_square
625.java
0.9
import java.io.BufferedInputStream; import java.util.Scanner; public class RookHome { static long MAX = 1_000_000_000; public static void main(String[] args) { Scanner s = new Scanner(new BufferedInputStream(System.in)); int n = s.nextInt(); int m = s.nextInt(); long[] vert = new long[n + 2]; vert[0] = 1;...
n_square
628.java
0.9
import java.util.*; public class Main { public static int n, m; public static int[] vert, group; public static int[][] horiz; public static boolean ok(int a, int b, int g) { int start, end; if (g == 0) { start = 1; end = vert.length > 0 ? vert[0] : (int)Math.pow(1...
n_square
630.java
0.9
import java.util.Scanner; public class Tokitsukaze { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); long k =sc.nextLong(); double[]p=new double[m]; for(int i = 0;i<m;i++){ p[i]=sc....
n_square
634.java
0.9
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import...
n_square
635.java
0.9
import java.util.*; import java.io.*; import java.util.Map.Entry; public class Codeforces { static int n; static double max; static int[] pre; public static void findIntensity(int l){ for(int i = 0, j = i + l; j < n + 1; i++, j++){ double res = (pre[j] - pre[i]) / (double) l; ...
n_square
655.java
0.9
import java.io.*; import java.lang.*; public class CF1003E{ public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] s = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int d = Integer.pars...
n_square
656.java
0.9
// Java Program to Find the minimum // distance between two numbers class MinimumDistance { int minDist( int arr[], int n, int x, int y) { int i, j; int min_dist = Integer.MAX_VALUE; for (i = 0 ; i < n; i++) { for (j = i + 1 ; j < n; j++) { if ((x == arr[i] && y == arr[j] || y == arr[i] && ...
n_square
68.java
0.9
import java.io.*; import java.util.*; import static java.lang.System.*; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringTokenizer st = new StringTokenizer(br.readLine().trim()); int n = Integer.valueOf(s...
n_square
681.java
0.9
import java.util.Scanner; public class Codeforces { public static Scanner input = new Scanner(System.in); public static void main(String[] args){ int n,k; n=input.nextInt(); k=input.nextInt(); String s=input.next(); int[] wtArray=new int[n]; for(int i=0;i<s.length...
n_square
686.java
0.9
//Atcoder import java.io.*; import java.util.*; public class Main { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(b...
n_square
688.java
0.9
// // _oo8oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/'==='\___ // .' \\| |// ...
n_square
690.java
0.9
import java.io.*; import java.util.*; public class Solution{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() ...
n_square
692.java
0.9
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Solution ss = new Solution(); ss.test(sc); } void test(Scanner sc){ int LEN = sc.nextInt(); int[] a = new int[LEN]; int[] b = new int[LEN]; for (...
n_square
697.java
0.9
// A Naive Java program to find // maximum sum rotation import java.util.*; import java.io.*; class GFG { // Returns maximum value of i*arr[i] static int maxSum( int arr[], int n) { // Initialize result int res = Integer.MIN_VALUE; // Consider rotation beginning with i // for all possible values of i. ...
n_square
7.java
0.9
import java.util.*; import java.lang.*; import java.io.*; public class TestClass { // function for finding size of set public static int set_size(int[] a, int N){ HashSet <Integer> newset = new HashSet <Integer>(); int i=0; while(i<N){ newset.add(a[i++]); } in...
n_square
700.java
0.9
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Cr500 { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n, x, status = -1; Set<Integer> a = new HashSet<>(), bitA = new HashSet<>(); ...
n_square
701.java
0.9
import java.util.*; public class B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int x = scanner.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); } ...
n_square
703.java
0.9
import java.util.*; import java.math.*; public class Main{ public static void main(String [] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int m=scan.nextInt(); int a[]=new int[m+1]; int i,j; int c=0; for(i=0;i<n;i++) { ...
n_square
705.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
n_square
706.java
0.9
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { new Main().go(); } PrintWriter out; Reader in; BufferedReader br; Main() throws IOException { try { //br = new BufferedReader( new FileReader("in...
n_square
710.java
0.9
// JAVA Code for Minimum number of jumps to reach end class GFG{ private static int minJumps( int [] arr, int n) { int jumps[] = new int [n]; // jumps[n-1] will hold the // result int i, j; if (n == 0 || arr[ 0 ] == 0 ) return Integer.MAX_VALUE; // if first element is 0, // end cannot be reached ...
n_square
72.java
0.9
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class DoggoRecoloring { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public...
n_square
720.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
n_square
729.java
0.9
/** * Created by Baelish on 8/28/2018. */ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class F_DSU { public static void main(String[] args)throws Exception { FastReader in = new FastReader(Sys...
n_square
731.java
0.9
import java.util.*; public class helloWorld { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int l = 1000, r = 0, u = 1000, b = 0; for(int i = 0; i < n; i++ ) { String str = in.next(); for(int j = 0; j < m; j++) if(...
n_square
732.java
0.9
import java.util.Scanner; public class FUck { public static void main(String args[]) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int k=scan.nextInt(); String t=scan.next(); int mx=0; for(int i=1;i<n;i++) { int gd=1; for(int j=0;j<i;j++) { if(t.charAt(j...
n_square
734.java
0.9
/* Dynamic Programming Java implementation of Maximum Sum Increasing Subsequence (MSIS) problem */ class GFG { /* maxSumIS() returns the maximum sum of increasing subsequence in arr[] of size n */ static int maxSumIS( int arr[], int n) { int i, j, max = 0 ; int msis[] = new int [n]; /* Initia...
n_square
74.java
0.9
import java.util.*; public class vas2 { public static void main( String[] args ) { Scanner in = new Scanner( System.in ); int n = in.nextInt(); String st = in.next(); int[] a = new int[n]; for ( int i = 0; i < n; i++ ) a[i] = st.charAt( i ) - 48; boolean c = false; for ( int i = 1; !c && i < n; i++ ) {...
n_square
741.java
0.9
class SmallestSubArraySum { // Returns length of smallest subarray with sum greater than x. // If there is no subarray with given sum, then returns n+1 static int smallestSubWithSum( int arr[], int n, int x) { // Initilize length of smallest subarray as n+1 int min_len = n + 1 ; // Pick every elemen...
n_square
75.java
0.9
import java.util.*; import java.lang.*; import java.io.*; public class java2 { public static void main(String[] args) { Scanner r = new Scanner(System.in); int n=r.nextInt(); int []l=new int[1005]; int []ri=new int[1005]; int []candy=new int[1005]; for(int i=1;i<=n;+...
n_square
759.java
0.9
import java.io.*; import java.util.Scanner; public class DivideCandies { public static void main(String[] args){ Scanner input = new Scanner(System.in); long n = input.nextLong(); int m = input.nextInt(); long[] a = new long[m]; for(int i = 0; i < m; i++) { if(i <= (n%m) && i != 0) { a[i] = n/m +...
n_square
762.java
0.9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class Solution { private static int[] dx = { -1, -1, -1, 0, 0, 1, 1, 1}; private static int[] dy = { -1, 0, 1, -1, 1, -1, 0, 1}; public ...
n_square
764.java
0.9
import java.util.Scanner;; public class JavaApplication2 { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n= sc.nextInt(); int li[]=new int[n]; for(int i = 0 ;i<n;i++){ li[i]=sc.nextInt(); } int max=0; int c=0; ...
n_square
769.java
0.9
import javax.print.attribute.standard.RequestingUserName; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReade...
n_square
790.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; ...
n_square
807.java
0.9
import java.util.Scanner; public class Amain { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int a[] = new int[100005]; int vis[] = new int[100005]; int maxx = -1; int n , k ; int e = 0 , s = 0 ; int ans = 0 ; n=sc.nextInt(); ...
n_square
811.java
0.9
import java.util.*; import java.math.*; public class Main { static class en implements Comparable<en>{ int w,h,dex; en(int a,int b,int c){ w=a; h=b; dex=c; } public int compareTo(en o) { return w-o.w; } } public static void main(String args[]) { Scanner cin=new Scanner(System.in); int n=ci...
n_square
815.java
0.9
// Java implementation of simple method to find // minimum difference between any pair class GFG { // Returns minimum difference between any pair static int findMinDiff( int [] arr, int n) { // Initialize difference as infinite int diff = Integer.MAX_VALUE; // Find the min diff by comparing differenc...
n_square
82.java
0.9
import java.util.Scanner; public class New_Year_and_Curling { static final double E = 0.00001; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int r = sc.nextInt(); double[] y = new double[n]; ...
n_square
821.java
0.9
import java.io.*; import java.util.*; public class Main { static final int MAXN= 1005; static final long MOD =1_000_000_007; static final boolean DEBUG= false; static int n, m; static long stlr[][]= new long[MAXN][MAXN],bell[]= new long[MAXN],occ[]; static PrintStream cerr=System.err; public static void main(S...
n_square
822.java
0.9
import java.io.*; import java.util.*; public class MainG { static StdIn in = new StdIn(); static PrintWriter out = new PrintWriter(System.out); static long M=(long)1e9+7; public static void main(String[] args) { char[] cs = in.next().toCharArray(); int n=cs.length; int[] x = new int[n]; for(int i=0; i<n;...
n_square
823.java
0.9
import java.util.*; public class HelloWorld{ public static void main(String []args){ final long MOD = 1000000007; Scanner scan = new Scanner(System.in); int now = 1; int maxStatements = scan.nextInt(); long[] dp = new long[maxStatements + 1]; dp[now] = 1; w...
n_square
826.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
n_square
831.java
0.9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class LogicalExpression { int N = 256; void solve() { Expression[] E = new Expression[N]; for (in...
n_square
839.java
0.9
// A Simple Java program to find longest common // subarray of two binary arrays with same sum class Test { static int arr1[] = new int []{ 0 , 1 , 0 , 1 , 1 , 1 , 1 }; static int arr2[] = new int []{ 1 , 1 , 1 , 1 , 1 , 0 , 1 }; // Returns length of the longest common sum in arr1[] // and a...
n_square
84.java
0.9
import java.io.*; import java.util.*; public class Codeforces913F { public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); int n = input.nextInt(); int a = input.nextInt(); int b = input.nextInt(); input.close(); final int mod = 998244353; int frac = multi...
n_square
840.java
0.9
// discussed with rainboy import java.io.*; import java.util.*; public class CF915D { static ArrayList[] aa; static boolean[] visited, instack; static int[] stack; static int cnt, h_, i_, j_; static boolean dfs1(int i) { if (visited[i]) { if (instack[i]) { h_ = i; return true; } return false; ...
n_square
843.java
0.9
/* * Created on 17.05.2019 */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * @author Wolfgang Weck */ public class A01Easy { private static interface Matrix { boolean get(int i, int j); int size(); } private static class MData implements Matrix { priva...
n_square
852.java
0.9
import java.util.Scanner; public class A961_Tetris { public static void main(String[] args) { Scanner input = new Scanner(System.in); int platforms = input.nextInt(); int in = input.nextInt(); int[] cols = new int[platforms]; int[] squares = new int[in]; for (int i = 0; i < in; i ++) { squares[i...
n_square
863.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
n_square
865.java
0.9
import java.io.*; import java.util.*; public class Codechef{ public static void main(String []args){ Scanner sc = new Scanner(System.in); int n=sc.nextInt(); Set<HashSet> s3 = new HashSet<>(); for(int j=0;j<n;j++){ String a=sc.next(); HashSet<Character> t...
n_square
877.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
n_square
894.java
0.9
import java.io.*; import java.math.BigInteger; import java.util.*; //Mann Shah [ DAIICT ]. //fast io public class Main { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; public static int n; public static int m; public static boolean valid(int i , int...
n_square
905.java
0.9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author pandusonu */ public class ...
n_square
906.java
0.9
import java.io.*; import java.util.*; public class Main { private static void solve(InputReader in, OutputWriter out) { int n = in.nextInt(); int m = in.nextInt(); String[] sa = new String[n]; for (int i = 0; i < n; i++) { sa[i] = in.next(); } Set<Inte...
n_square
908.java
0.9
import java.util.*; import java.lang.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.*; public class Main { public static void main(String[] args) throws Exception{ FastReader sc=new FastReader(); ...
n_square
911.java
0.9
// Java program to count // inversions in an array class Test { static int arr[] = new int [] { 1 , 20 , 6 , 4 , 5 }; static int getInvCount( int n) { int inv_count = 0 ; for ( int i = 0 ; i < n - 1 ; i++) for ( int j = i + 1 ; j < n; j++) if (arr[i] > arr[j]) inv_count++; return inv_co...
n_square
92.java
0.9
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ static ArrayList a[]=new ArrayList[200001]; static int Count(int a[][],int n) { dsu d=new dsu(n); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(a[i][j]==0) { d.union(i, j); }...
n_square
922.java
0.9
//package codeforces; import java.util.Scanner; public class Fingerprints { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] code = new int[scanner.nextInt()]; int[] prints = new int[scanner.nextInt()]; for (int i = 0; i < code.length; i++) { code[i] = scanner.ne...
n_square
928.java
0.9
import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable; import jdk.management.cmm.SystemResourcePressureMXBean; import java.awt.*; import java.io.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.util.List; import java.math.*; public class Newbie { ...
n_square
933.java
0.9
import java.util.*; import java.lang.*; class Main { static void minAbsSumPair( int arr[], int arr_size) { int inv_count = 0 ; int l, r, min_sum, sum, min_l, min_r; /* Array should have at least two elements*/ if (arr_size < 2 ) { System.out.println( "Invalid Input" ); return ; } /* Initia...
n_square
94.java
0.9
import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparat...
n_square
943.java
0.9
import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.nio.charset.Charset; import java.util.*; import static java.lang.System.gc; import static java.lang.System.out; public class Main { Scanner scanner = new Scanner(System.in); public static void main(String[]...
n_square
949.java
0.9
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); void run(){ int q=in.nextInt(); for(int i=0;i<q;i++){ out.println(work()); } out...
n_square
986.java
0.9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.function.Function; public class P1196D2 { static boolea...
n_square
987.java
0.9
import java.util.*; import java.io.*; public class CodeForces { public static void main(String[] args)throws IOException { Scanner sc=new Scanner(System.in); //Scanner sc=new Scanner(new File("ip.txt")); int t,i,j,n,k,x,y,z,min1,min2,min3,arr1[],arr2[],arr3[]; String s; char[] s1,s2,s3; t=sc.nextInt(...
n_square
988.java
0.9
//q4 import java.io.*; import java.util.*; import java.math.*; public class q4 { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); int query = in.nextInt(); while (qu...
n_square
989.java
0.9
//q4 import java.io.*; import java.util.*; import java.math.*; public class q4 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int query = in.nextInt(); while (query -- > 0) { int n = in.nextInt(); int k = in.nextIn...
n_square
990.java
0.9
//package contest1196; import java.util.*; import java.io.*; public class D { public static int[][] dp = new int[200005][3]; public static void main(String[] args) { Scanner cin = new Scanner(System.in); PrintWriter cout = new PrintWriter(System.out); int q = cin.nextInt(); int[] a = new int[200005]; ...
n_square
991.java
0.9
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import j...
n_square
992.java
0.9
import java.util.*; import java.io.*; public class RGBSubstring { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int Q = scanner.nextInt(); while(Q-->0) { int N = scanner.nextInt(); ...
n_square
993.java
0.9
// Java program to find triplets in a given // array whose sum is zero import java.util.Arrays; import java.io.*; class GFG { // function to print triplets with 0 sum static void findTriplets( int arr[], int n) { boolean found = false ; // sort array elements Arrays.sort(arr); for ( int i= 0 ; i<n...
n_square
144.java
0.9
// JAVA Code for Dynamic Programming | // Set 9 (Binomial Coefficient) import java.util.*; class GFG { static int binomialCoeff( int n, int k) { int C[] = new int [k + 1 ]; // nC0 is 1 C[ 0 ] = 1 ; for ( int i = 1 ; i <= n; i++) { // Compute next row of pascal // triangle using the previo...
n_square
294.java
0.9
// Java program to Rearrange positive and negative // numbers in a array class GFG { /* Function to print an array */ static void printArray( int A[], int size) { for ( int i = 0 ; i < size; i++) System.out.print(A[i] + " " ); System.out.println( "" ); ; } /* Function to reverse an array. An ar...
n_square
31.java
0.9
// Java program to find Minimum // number of jumps to reach end class GFG { // Returns Minimum number // of jumps to reach end static int minJumps( int arr[], int n) { // jumps[0] will // hold the result int [] jumps = new int [n]; int min; // Minimum number of jumps // needed to reach last //...
n_square
340.java
0.9
// Java program to find Minimum // number of jumps to reach end class GFG { // Returns Minimum number // of jumps to reach end static int minJumps( int arr[], int n) { // jumps[0] will // hold the result int [] jumps = new int [n]; int min; // Minimum number of jumps // needed to reach last //...
n_square
73.java
0.9
// Java program to rearrange the array // as per the given condition import java.util.*; import java.lang.*; public class GfG{ // function to rearrange the array public static void rearrangeArr( int arr[], int n) { // total even positions int evenPos = n / 2 ; // total odd positions int oddPos =...
nlogn
10.java
0.7
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class ladder { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int problems = sc.nextInt(); for (int i = 0; i < problems; i++) { int numPlanks = sc.nextInt();...
nlogn
1019.java
0.7
import java.io.*; import java.util.*; public class ayyyyyy { public static void main(String[] args) { new ayyyyyy(); } Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int t, n; int[] a; ayyyyyy() { t = in.nextInt(); while (t --> 0) { a = new int[n = in.nextInt()]...
nlogn
1020.java
0.7
import java.io.*; import java.util.*; import java.util.Arrays; public class Main { static void merge(int arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays */ int L[] = new int...
nlogn
1024.java
0.7
import java.util.*; import java.math.*; public class Split { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int k= sc.nextInt(); int a[] = new int[n]; int d[] = new int[n-1]; for(int i=0;i<n;i++) { a[i] = sc.nextInt(); if(i>0) d[i-1] = a[i-1] -...
nlogn
1030.java
0.7
import java.util.*; public class Main { public static void main(String[] args) { Scanner in =new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++) arr[i] = in.nextInt(); for(int i = n-1; i > 0; i--) arr[i] -= arr[i-1]; arr[0] = 0; A...
nlogn
1031.java
0.7
import java.util.*; import java.io.*; import java.math.*; public class Solution{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseI...
nlogn
1032.java
0.7
import java.io.*; import java.util.*; import javax.lang.model.util.ElementScanner6; public class codef { public static void main(String ar[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer nk=new StringTokenizer(br.readLine()); ...
nlogn
1033.java
0.7
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; //BigInteger A; //A= BigInteger.valueOf(54); //ArrayList<Integer> a=new ArrayList<>(); //TreeSet<Integer> ts=new TreeSet<>(); //HashMap<Integer,Integer> hm=new HashMap<>(); public final class Cf { public static void main(String[]args) ...
nlogn
1034.java
0.7
// Java program to find the // to calculate the product // of max element of first // array and min element of // second array import java.util.*; import java.lang.*; class GfG { // Function to calculate // the product public static int minMaxProduct( int arr1[], int arr2[], int n1, int n2) { ...
nlogn
108.java
0.7
// Java Program to find max subarray // sum excluding some elements import java.util.*; class GFG { // Utility function for findMaxSubarraySum() // with the following parameters // A => Array A, // B => Array B, // n => Number of elements in Array A, // m => Number of elements in Array B static int...
nlogn
116.java
0.7
// Java code to find maximum triplet sum import java.io.*; import java.util.*; class GFG { // This function assumes that there are // at least three elements in arr[]. static int maxTripletSum( int arr[], int n) { // sort the given array Arrays.sort(arr); // After sorting the array. // Add last...
nlogn
136.java
0.7
// Java implementation of smallest difference // triplet import java.util.Arrays; class GFG { // function to find maximum number static int maximum( int a, int b, int c) { return Math.max(Math.max(a, b), c); } // function to find minimum number static int minimum( int a, int b, int c) { ret...
nlogn
138.java
0.7
// Java program to find the row // with maximum number of 1s import java.io.*; class GFG { static int R = 4 , C = 4 ; // Function to find the index of first index // of 1 in a boolean array arr[] static int first( int arr[], int low, int high) { if (high >= low) { // Get the middle index int mi...
nlogn
145.java
0.7
// Java program to print the array in given order import java.util.Arrays; public class GFG { // Function which arrange the array. static void rearrangeArray( int arr[], int n) { // Sorting the array elements Arrays.sort(arr); int [] tempArr = new int [n]; // To store modified array // Adding nu...
nlogn
15.java
0.7
// Java program to implement merge sort in singly linked list // Linked List Class class LinkedList { static Node head; // head of list /* Node Class */ static class Node { int data; Node next, prev; // Constructor to create a new node Node( int d) { data = d; next = prev = null ; } } ...
nlogn
174.java
0.7
//Java program to generate binary numbers from 1 to n import java.util.LinkedList; import java.util.Queue; public class GenerateBNo { // This function uses queue data structure to print binary numbers static void generatePrintBinary( int n) { // Create an empty queue of strings Queue<String> q = new L...
nlogn
234.java
0.7
// Java program to find length of longest increasing subsequence // in O(n Log n) time import java.io.*; import java.util.*; import java.lang.Math; class LIS { // Binary search (note boundaries in the caller) // A[] is ceilIndex in the caller static int CeilIndex( int A[], int l, int r, int key) { w...
nlogn
315.java
0.7