上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 自定义排序规则 假设nums任意两个数字的字符串格式x和y,则 若拼接字符串 x + y > y + x, 则 m > n; 反之,x + y < y + x, 则 n < m; 时间复杂度:O(nlogn) 空间复杂度:O(n) class Solution { public: string mi 阅读全文
posted @ 2020-04-27 23:11 NaughtyCoder 阅读(98) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/ 思路 关键点 还是从位运算的角度,考虑数字的二进制形式,各二进制位出现的次数都是3的倍数。说明出现了三次;因此,统计所有数字的各 阅读全文
posted @ 2020-04-23 13:37 NaughtyCoder 阅读(91) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/qiu-12n-lcof/ 位运算 本题要求不使用乘除法,for/while/if/else/switch/case等关键字及条件判断语句; 使用递归来做,通常递归中条件的结束需要用到if,本题可以利用逻辑与的“短路”完成本 阅读全文
posted @ 2020-04-23 13:05 NaughtyCoder 阅读(137) 评论(0) 推荐(0)
摘要: ping 测试网络连通性 ifconfig 显示当前系统中所有网络设备,基于ICMP协议开发的。 netstat 参数 -a (all)显示所有选项,netstat 默认不显示 LISTEN 相关。 -t (tcp)仅显示 tcp 相关选项 -u (udp)仅显示 udp 相关选项 -n 不显示别名 阅读全文
posted @ 2020-04-22 21:33 NaughtyCoder 阅读(324) 评论(0) 推荐(0)
摘要: 套接字格式 通用套接字格式 IPv4套接字地址格式 IPv6套接字地址格式 本地套接字地址格式 常用socket API socket创建套接字 bind绑定套接字和套接字地址 作用:将参数sockfd和addr绑定在一起,使sockfd这个用于网络通讯的文件描述符监听addr所描述的地址和端口号。 阅读全文
posted @ 2020-04-22 19:56 NaughtyCoder 阅读(250) 评论(0) 推荐(0)
摘要: 插入排序 每次将一个待排序的记录,按其关键字大小插入到前面已经排好序的子表中适当位置,直到全部记录插入完成为止; 直接插入排序 思想 待排序的记录放在数组R[0, n - 1]中; 排序过程中将R分成两个子区间,有序区R[0, i-1], 无序区R[i, n - 1]; 将当前无序区的第1个记录,插 阅读全文
posted @ 2020-04-22 17:26 NaughtyCoder 阅读(118) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/da-yin-cong-1dao-zui-da-de-nwei-shu-lcof/ class Solution { public: vector<int> printNumbers(int n) { vector<int> 阅读全文
posted @ 2020-04-20 16:51 NaughtyCoder 阅读(62) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/bu-ke-pai-zhong-de-shun-zi-lcof/ 思路 时间复杂度:O(nlogn) 空间复杂度: O(1) 将数据排序 第一次遍历数组(过滤掉有重复元素的),如果遇到非0元素,并且前后两个数相等,说明不是顺 阅读全文
posted @ 2020-04-20 16:35 NaughtyCoder 阅读(74) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/gou-jian-cheng-ji-shu-zu-lcof/ 时间复杂度O(n) 空间复杂度O(1) class Solution { public: vector<int> constructArr(const vecto 阅读全文
posted @ 2020-04-20 16:32 NaughtyCoder 阅读(69) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/bu-yong-jia-jian-cheng-chu-zuo-jia-fa-lcof/ 位运算 分析十进制是如何做加法的?以5 + 17为例说明 1. 只做各位相加不进位 个位:5 + 7 = 12, 不要进位是2,十位: 阅读全文
posted @ 2020-04-20 15:57 NaughtyCoder 阅读(101) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页