码迷,mamicode.com
首页 >  
搜索关键字:while True    ( 51585个结果
快速幂取模
long long myPow(long long x, int n) { long long ans = 1; while(n){ if(n % 2 != 0){ ans *= x; ans %= modN; } x *= x; x %= modN; n /= 2; } return ans; } ...
分类:其他好文   时间:2021-04-08 13:55:01    阅读次数:0
Jackson使用@JsonTypeInfo反序列化多态类型(根据标识解析为子类对象)
问题场景 jackson可以将多态类型JSON序列化. 但在反序列化时会因为找不到具体的类而失败. 举例:创建4个POJO类 @Data public class AbstractTarget { } @Data @EqualsAndHashCode(callSuper = true) class ...
分类:Web程序   时间:2021-04-08 13:32:22    阅读次数:0
题目:9. 回文数
方式一(将整数转换为字符串,在转换为字符数组): public boolean isPalindrome(int x) { if (x < 0) { return false; } char[] chars = new String(Integer.toString(x)).toCharArray( ...
分类:其他好文   时间:2021-04-08 13:10:24    阅读次数:0
二叉树——102. 二叉树的层序遍历
二叉树——102. 二叉树的层序遍历 题目: 思路: 就是层序遍历,一层层扫下去,然后通过队列去实现,一个队列先暂存这一层的所有结点,然后另一个队列通过push_back的方式,实现从左到右的访问。 代码: class Solution { public: vector<vector<int>> l ...
分类:其他好文   时间:2021-04-08 12:59:26    阅读次数:0
10-2 "乞丐"
比较for和while 代码比较复制代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public class HelloWorld { public static void main(String[] args) { //使用while打印0到4 int i =  ...
分类:其他好文   时间:2021-04-08 12:54:22    阅读次数:0
tsx 引入文件找不到
问题1:tsx文件找不到 根目录新建一个tsconfig.json { "compilerOptions": { "jsx": "react", "outDir": "./dist", "module": "es6", "target": "es5", "allowJs": true, "allow ...
分类:其他好文   时间:2021-04-07 11:32:12    阅读次数:0
基础算法学习--dfs和bfs
#dfs的模板 注意bool判断是否走过这个点并注意回溯的处理。 注意条件判断和边界问题。 //边界判断即剪枝 if(chk()) return; if(over(BianJie)) return; if(bool = false)//未搜索过 bool = true; //赋值或纪录 dfs(n ...
分类:编程语言   时间:2021-04-07 11:21:16    阅读次数:0
统计数组中每个值出现的次数, 统计对象中每个字符出现的次数
// 统计数组中 相同值出现的次数 var ary = [1,2,1,1,1,2,3] let obj = {} for(let i = 0 ; i < ary.length; i++) { if(obj[ary[i]]){ //如果obj中有值, +1 (如果数组中有值 是0,注意true 和 f ...
分类:编程语言   时间:2021-04-07 11:17:33    阅读次数:0
秒杀活动下的公平队列抢购机制
package com.easyagu.liwei.list;import redis.clients.jedis.Jedis;/** * 秒杀案例 */public class SeckillDemo { public static void main(String[] args) { Secki ...
分类:其他好文   时间:2021-04-07 11:07:01    阅读次数:0
二分查找, Binary Search
class Solution { public: int searchInsert(vector<int> &nums, int target) { int low = 0; int high = nums.size() - 1; //为了严谨 <= while (low <= high) { in ...
分类:其他好文   时间:2021-04-07 10:57:40    阅读次数:0
51585条   上一页 1 ... 38 39 40 41 42 ... 5159 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!