题目在这里 A.手动打表找规律得组合数 n -= 2, m -= 2, ans = C(n, m) #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll fac[]; ll calc(ll x, ) { ll ret = ; , x = x * x % Mod) ) ret = ret * x % Mod; return ret; } int main() { ios::sync_with_stdio(…
Problem Given an integer (signed bits), write a function to check whether it . Example: Given num = , , return false. Follow up: Could you solve it without loops/recursion? Code class Solution { public: bool isPowerOfFour(int num) { ) && ((num &am…
Problem Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? Code: class Solution { public: bool isPowerOfThree(int n) { if (n <= 0) return 0; int max_pow3 = log10(I…
心情还是有问题,保持每日更新,只能如此了. Problem Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). Example: Given binary tree {,,,#,#,,}, ···· / \ / \ Result return its level order traversal as: [ [],…
本来打算写redis的,时间上有点没顾过来,只能是又拿出点自己的存货了. Problem Given an array nums, write a function to move all 's to the end of it while maintaining the relative order of the non-zero elements. Example: Given nums = [, , , , ], after calling your function, nums shou…
Problem: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to…
leetcode真的是一个学习阅读理解的好地方 860. 柠檬水找零 """ 因为用户支付的只会有5.10.20 对于10元的用户必须找一个5 对于20元的用户可以找(三个5)或者(一个10一个5),每次都从大的开始找起来 """ class Solution: def lemonadeChange(self, bills) -> bool: five = 0 ten = 0 for i in bills: if i == 5: five…