MCPcopy Create free account
hub / github.com/Flamewaker/JavaPersonalSummary / lastRemaining

Method lastRemaining

Code/leetcode/offer1/Offer62.java:44–53  ·  view source on GitHub ↗

数学解法: (当前索引值 + m) % 上一轮剩余数字的个数 最后一轮剩下2个人,所以从2开始反推。 当只剩下一位的时候,就是所需要的结果,此结果的当前索引值为0。 根据当前索引值可以进行反推,得到该值在上一轮中的索引值。也就是:上一轮的索引值 = (当前索引值 + m) % 上一轮剩余数字的个数 @param n @param m @return

(int n, int m)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected