MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / maxScore

Method maxScore

MaximizeTheMinimumGameScore.java:52–69  ·  view source on GitHub ↗
(int[] points, int m)

Source from the content-addressed store, hash-verified

50x = (midVal + points[I] - 1 )/ points[I]
51*/
52//code
53class Solution {
54 public long maxScore(int[] points, int m) {
55 int n = points.length;
56 if (m < n) return 0;
57
58 long left = 1, right = (long) 1e18, maxPossibleMinScore = 0;
59
60 while (left <= right) {
61 long targetScore = left + (right - left) / 2;
62 if (canAchieve(points, n, m, targetScore)) {
63 maxPossibleMinScore = targetScore;
64 left = targetScore + 1;
65 } else {
66 right = targetScore - 1;
67 }
68 }
69
70 return maxPossibleMinScore;
71 }
72

Callers

nothing calls this directly

Calls 1

canAchieveMethod · 0.95

Tested by

no test coverage detected