回到首页

输入关键词,多个关键词用空格分隔。

← 面试刷题笔记 · 系列目录

Jugs of Water

约 1 分钟
本页目录

Jugs of Water

You have a five-quart jug, a three-quart jug, andn an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly half of the jug would be impossible.

Solution

  1. Fill 3, into 5. 3/5, 0/3
  2. Fill 3, into 5. 5/5, 1/3
  3. Clear 5, 3 into 5. 1/5, 0/3
  4. Fill 3, into 5. 4/5, 0/3

相关文章