V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
doraon
V2EX  ›  算法

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

  •  
  •   doraon · Jun 18, 2021 · 1084 views
    This topic created in 1786 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   ·   2963 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 06:29 · PVG 14:29 · LAX 23:29 · JFK 02:29
    ♥ Do have faith in what you're doing.