package jz.bm;import jz.Interval;import java.util.ArrayList;
import java.util.HashMap;public class bm9 {public void merge(int A[], int m, int B[], int n) {int i = m - 1, j = n - 1, k = m + n - 1;while (i >= 0 || j >= 0) {int a = i >= 0 ? A[i] : Integer.MIN_VALUE;int b = j >= 0 ? B[j] : Integer.MIN_VALUE;if (a > b) {A[k] = a;i--;} else {A[k] = b;j--;}k--;}}public boolean judge (String str) {if (str == null || str.equals("")) {return true;}for (int i = 0; i < str.length() / 2; i++) {if (str.charAt(i) != str.charAt(str.length() - 1 - i)) {return false;}}return true;}public ArrayList<Interval> merge(ArrayList<Interval> intervals) {intervals.sort((o1, o2) -> o1.start - o2.start);int pre = 0, cur = 1;while (cur < intervals.size()) {if (intervals.get(pre).end < intervals.get(cur).start) {pre = cur;cur++;} else if (intervals.get(pre).end >= intervals.get(cur).start) { intervals.get(cur).start = intervals.get(pre).start;intervals.get(cur).end = Math.max(intervals.get(pre).end, intervals.get(cur).end);intervals.remove(pre);}}return intervals;}public String solve (String str) {StringBuilder stringBuilder = new StringBuilder();for (int i = str.length() - 1; i >= 0; i--) {stringBuilder.append(str.charAt(i));}return stringBuilder.toString();}public int maxLength (int[] arr) {if (arr.length == 0) {return 0;}int res = 0;int i = 0, j = 0;HashMap<Integer, Integer> map = new HashMap<>();while (j < arr.length) {if (map.containsKey(arr[j])) {i = Math.max(i, map.get(arr[j]) + 1);}map.put(arr[j], j);res = Math.max(res, j - i + 1);j++;}return res;}public int maxArea (int[] height) {if (height.length <= 1) {return 0;}int i = 0, j = height.length - 1, res = 0;while (i < j) {res = Math.max(res, Math.min(height[i], height[j]) * (j - i));if (height[i] < height[j]) {i++;} else {j--;}}return res;}
}