minimum absolute value
Posted apanda009
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了minimum absolute value相关的知识,希望对你有一定的参考价值。
Given three sorted arrays A[], B[] and C[], find 3 elements i, j and k from A, B and C respectively such that max(abs(A – B[j]),
abs(B[j] – C[k]), abs(C[k] – A)) is minimized. Here abs() indicates absolute value. Example : Input: A[] = {1, 4, 10} B[] = {2, 15, 20} C[] = {10, 12} Output: 10 15 10。 10 from A, 15 from B and 10 from C Input: A[] = {20, 24, 100} B[] = {2, 19, 22, 79, 800} C[] = {10, 12, 23, 24, 119} Output: 24 22 23。24 from A, 22 from B and 23 from C
每次移动3个pointer 里面最小的那个就好了。记录整个过程找最近的3个数。3个数之中median没意义,距离主要由最小和最大决定。基本就是这个思路。很快编完就过了编程阶段。
以上是关于minimum absolute value的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode --- 1200. Minimum Absolute Difference 解题报告
leetcode1200. Minimum Absolute Difference
530. Minimum Absolute Difference in BST
530. Minimum Absolute Difference in BST