05 2020 档案

摘要:题目链接:https://leetcode-cn.com/problems/ba-zi-fu-chuan-zhuan-huan-cheng-zheng-shu-lcof/ 应该先去除字符串首部的空格,然后再判断正负。 难点在于处理溢出。 INT_MAX 2147483647 INT_MIN -214 阅读全文
posted @ 2020-05-31 10:14 NaughtyCoder 阅读(106) 评论(0) 推荐(0)
摘要:ping 测试网络连通性 ifconfig 显示当前系统中所有网络设备,基于ICMP协议开发的。 netstat 参数 -a (all)显示所有选项,netstat 默认不显示 LISTEN 相关。 -t (tcp)仅显示 tcp 相关选项 -u (udp)仅显示 udp 相关选项 -n 不显示别名 阅读全文
posted @ 2020-05-29 22:14 NaughtyCoder 阅读(801) 评论(0) 推荐(0)
摘要:bind 客户端可以调用bind函数吗?可以,可以指定端口 详见复习资料 客户端为何不调用bind函数,什么时候像套接字分配IP和端口号 listen 它现在定义的是已完成连接队列的最大长度,表示的是已建立的连接(established connection),正在等待被接收(accept 调用返回 阅读全文
posted @ 2020-05-28 18:50 NaughtyCoder 阅读(221) 评论(0) 推荐(0)
摘要:题目链接:https://www.acwing.com/problem/content/description/86/ 双指针 快慢指针,快指针一次走两步,慢指针一次走一步,如果快指针无法继续前进,没有环; 否则,当快指针与慢指针第一次相遇以后,令快指针等于头结点,快慢指针各自每次走一步,再次相遇的 阅读全文
posted @ 2020-05-08 20:33 NaughtyCoder 阅读(88) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode cn.com/problems/jian sheng zi ii lcof/ 贪心 阅读全文
posted @ 2020-05-08 19:54 NaughtyCoder 阅读(68) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/ 贪心 class Solution { public: int cuttingRope(int n) { if(n <= 3) return 1 * (n - 1); int res 阅读全文
posted @ 2020-05-08 19:23 NaughtyCoder 阅读(84) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/ 递归 直接用二叉搜索树的后序遍历构建二叉树(利用二叉搜索树的性质,根节点的左子树都比他小,右子树都比他大),如果构建成功,返 阅读全文
posted @ 2020-05-06 20:36 NaughtyCoder 阅读(116) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/ 思路 问题简化 考虑一个简单问题:数组中所有数组只有一个数出现了一次,其它数字都出现了两次? 利用异或的性质,两数相同,异或结果为0, 阅读全文
posted @ 2020-05-06 20:32 NaughtyCoder 阅读(110) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/ping-heng-er-cha-shu-lcof/ 递归 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode 阅读全文
posted @ 2020-05-06 20:20 NaughtyCoder 阅读(92) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/er-cha-shu-zhong-he-wei-mou-yi-zhi-de-lu-jing-lcof/ 递归 时间复杂度:O(n) 空间复杂度:O(n) /** * Definition for a binary tree 阅读全文
posted @ 2020-05-06 20:19 NaughtyCoder 阅读(94) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof/ 归并排序 class Solution { public: int merge(vector<int>& nums, int l, int r) { if(l 阅读全文
posted @ 2020-05-04 15:01 NaughtyCoder 阅读(90) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ 搜索与回溯 class Solution { public: int get_single_sum(int x){ int s = 0; while(x 阅读全文
posted @ 2020-05-04 14:20 NaughtyCoder 阅读(79) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof/ dfs class Solution { public: bool exist(vector<vector<char>>& board, string word) 阅读全文
posted @ 2020-05-04 13:45 NaughtyCoder 阅读(76) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode cn.com/problems/biao shi shu zhi de zi fu chuan lcof/ 阅读全文
posted @ 2020-05-04 10:41 NaughtyCoder 阅读(86) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/shu-zi-xu-lie-zhong-mou-yi-wei-de-shu-zi-lcof/ 数学 先确定第n位所在的数字是几位数; n - 10 - 90 * 2 - 900 * 3 - 9000 * 4 ... 确定第n 阅读全文
posted @ 2020-05-04 10:37 NaughtyCoder 阅读(114) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode cn.com/problems/er cha sou suo shu de hou xu bian li xu lie lcof/ 递归 阅读全文
posted @ 2020-05-04 10:20 NaughtyCoder 阅读(83) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/shu-ju-liu-zhong-de-zhong-wei-shu-lcof/ 没有排序的数组 同面试题39题,利用分治的思想找出数组的中位数 插入 找中位数 时间复杂度 O(1) O(n) 排序数组 利用一个排序的数组,数 阅读全文
posted @ 2020-05-03 19:46 NaughtyCoder 阅读(105) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/ 双指针算法 i在前,j在后,分别指向不重复子串的头和尾;使用一个哈希表每个字符出现的次数,当遍历到j时,发现s[ 阅读全文
posted @ 2020-05-03 19:37 NaughtyCoder 阅读(99) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/1nzheng-shu-zhong-1chu-xian-de-ci-shu-lcof/ 按位统计 以abcdef为例,固定其中一位为1,然后统计: 0 ~ ab - 1: 左边:ab:00 ~ ab - 1, ab个 右边: 阅读全文
posted @ 2020-05-03 19:28 NaughtyCoder 阅读(101) 评论(0) 推荐(0)