doraon
V2EX  ›  算法

请教一个集合组合取最小集合问题

  •  
  •   doraon · Jun 18, 2021 · 1102 views
    This topic created in 1792 days ago, the information mentioned may be changed or developed.

    有下面这样的数据结构

    [
    	[{a,1},{b,2},{c,3},...],
    	[{d,4},{e,5},{f,6},...],
    	[{g,7},{h,8},{i,9},...],
    	...
    ]
    

    要把集合里的元素进行组合 例如

    (a,1)(d,4)(g,7) (a,1)(d,4)(h,8) (a,1)(d,4)(i,9)
    ...
    

    之后在组合后的结果集中找到数字 sum 后最小的那个组合 想请问大伙有没好的思路

    doraon
        1
    doraon  
    OP
       Jun 18, 2021
    尝试用 guava 里的 Sets.cartesianProduct 这个方法直接提示超出最大值
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1036 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:31 · PVG 02:31 · LAX 11:31 · JFK 14:31
    ♥ Do have faith in what you're doing.