package Algorithmus;

import java.util.Arrays;
import java.util.stream.Stream;

public class Allgemeine_Übungen {

	public static void main(String[] args) {
//		int [] nums = {3, 4, -7, 3, 1, 3, 1, -4, -2, -2};
//		subarraysWith0Sum(nums);
		String str = "Hallo dies ist ein Test";
		String[] worte = str.split(" "); 
		
		Stream<String> stream = Arrays.stream(worte);
		stream
		.map(String::toUpperCase)
		.filter(w -> w.startsWith("H") )
		.forEach(System.out::println);
		
		
//		grossmacher("");
	}
	
	public static void grossmacher(String str) {
		
		System.out.println("Ergebnis: " + str.toUpperCase() + "\nZeichen: " + str.length());
		
	}

	public static void subarraysWith0Sum(int[] arr) {
		int sum = 0;

		for (int i = 0; i < arr.length; i++) {
			sum = 0;
			for (int j = i; j < arr.length; j++) {
				sum += arr[j];
				if (sum == 0)
					System.out.println("subarray: " + arr[i] + " .... " + arr[j]);

			}
		}
	}

	public static void findApair(int[] arr, int target) {

		for (int i = 0; i < arr.length - 1; i++)
			for (int j = i + 1; j < arr.length - 1; j++)
				if (arr[i] + arr[j] == target) {
					System.out.println("Pair found (" + arr[i] + " ," + arr[j] + ")");
					break;
				}

	}

}
