src/Dynamic_Stack_Queue/DQClient.java
public static void firstNegativeInteger(int[] arr, int k) throws Exception {

		DynamicQueue q = new DynamicQueue();

		for (int i = 0; i < k; i++) {

			if (arr[i] < 0) {
				q.enqueue(i);
			}
		}

		for (int i = k; i < arr.length; i++) {
			if (q.isEmpty())
				System.out.println("0");

			else
				System.out.println(arr[q.getFront()]);

			if (!q.isEmpty() && q.getFront() <= i - k)
				q.dequeue();

			if (arr[i] < 0)
				q.enqueue(i);

		}

		if (q.isEmpty())
			System.out.println("0");
		else
			System.out.println(arr[q.getFront()]);

	}
//	first negative integer in every window of size k
first negative integer in every window of size k
first negative integer in every window of size k
public static void firstNegativeInteger(int[] arr, int k) throws Exception {
		DynamicQueue q = new DynamicQueue();
		for (int i = 0; i < k; i++) {
			if (arr[i] < 0) {
				q.enqueue(i);
			}
		}
		for (int i = k; i < arr.length; i++) {
			if (q.isEmpty())
				System.out.println("0");
			else
				System.out.println(arr[q.getFront()]);
			if (!q.isEmpty() && q.getFront() <= i - k)
				q.dequeue();
			if (arr[i] < 0)
				q.enqueue(i);
		}
		if (q.isEmpty())
			System.out.println("0");
		else
			System.out.println(arr[q.getFront()]);
	}
public static void firstNegativeInteger ( int [ ] arr , int k ) throws Exception { DynamicQueue q = new DynamicQueue ( ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( arr [ i ] < 0 ) { q . enqueue ( i ) ; } } for ( int i = k ; i < arr . length ; i ++ ) { if ( q . isEmpty ( ) ) System . out . println ( "0" ) ; else System . out . println ( arr [ q . getFront ( ) ] ) ; if ( ! q . isEmpty ( ) && q . getFront ( ) <= i - k ) q . dequeue ( ) ; if ( arr [ i ] < 0 ) q . enqueue ( i ) ; } if ( q . isEmpty ( ) ) System . out . println ( "0" ) ; else System . out . println ( arr [ q . getFront ( ) ] ) ; }
first negative integer in every window of size k
first negative integer in every window of size k