Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. Example 1: Input: numerator = 1, denominator = 2 Output…
public class Solution { public String fractionToDecimal(int numerator, int denominator) { HashMap<Long,Integer> maps = new HashMap<>();//store divid number List<Long> number = new ArrayList<>(); int index = 0; int beginIndex = -1;…
思路: 模拟. 实现: class Solution { public: string fractionToDecimal(int numerator, int denominator) { long long a = numerator, b = denominator; string ans = ""; ) ans += '-'; a = abs(a); b = abs(b); ans += to_string(a / b); a %= b; if (!a) return ans;…
题目描述: 自己的提交: class Solution: def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]: ans = [] dic = {} for v,i in enumerate(groupSizes): if i in dic: dic[i].append(v) if len(dic[i]) == i: ans.append(dic[i]) dic.pop(i) else: dic[i] = [v] i…