上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页
摘要: 思路 1. 一圈圈的打印,开始点为左上角(0,0) 1. 第一圈:(0,0) 2. 第二圈:(1,1) 3. 第N圈:(n,n) 2. 总共可以打印多少圈,n为行与列的一半,超出就终止 python实现 def print_one_circle(array_input, rows, cols, st 阅读全文
posted @ 2020-10-28 14:19 威威后花园 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 给定两个非空二叉树 s 和 t,检验 s 中是否包含和 t 具有相同结构和节点值的子树。s 的一个子树包括 s 的一个节点和这个节点的所有子孙。s 也可以看做它自身的一棵子树。 示例 1:给定的树 s: 3 / \ 4 5 / \ 1 2给定的树 t: 4 / \ 1 2返回 true,因为 t 与 阅读全文
posted @ 2020-10-26 22:19 威威后花园 阅读(108) 评论(0) 推荐(0) 编辑
摘要: // 求a b 两个字符串的编辑距离 // a b // 0 1 // a 0 // b 1 // c 2 int calTwoStr(string a, string b){ int aSize = a.length(); int bSize = b.length(); int dp[bSize] 阅读全文
posted @ 2020-10-25 21:52 威威后花园 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 傻瓜式安装c++的环境 step1: 下载安装vs code 下载地址: https://code.visualstudio.com/ step2: vs code内下载使用插件,如下图下载安装3个插件即可 step3 写c++代码,就可以运行了 阅读全文
posted @ 2020-10-25 15:19 威威后花园 阅读(150) 评论(0) 推荐(0) 编辑
摘要: def quick_sort(array, left, right): if left >= right: return low = left high = right key = array[low] while left < right: while left < right and array 阅读全文
posted @ 2020-10-22 14:44 威威后花园 阅读(116) 评论(0) 推荐(0) 编辑
摘要: # 求根号2 def solution(): # 初始化x x = 2 # 目标函数fx fx = x**2 - 2 # 优化求解fx while fx > 0.001: x = x - (fx * 1.0 / (2*x)) fx = x**2 - 2 return x 1. 使用牛顿迭代法,关键代 阅读全文
posted @ 2020-10-22 09:37 威威后花园 阅读(393) 评论(0) 推荐(0) 编辑
摘要: 思路一:非递归方法 1. 找到两个节点的路径的逆序链表,将题转换成两个链表第一个公共节点的问题。 1.2 两个链表求第一个公共节点 class Solution { public: ListNode *getIntersectionNode(ListNode *headA, ListNode *he 阅读全文
posted @ 2020-10-21 22:42 威威后花园 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 方法1 使用优先队列,时间复杂度为,kn * log k // 合并K个已经排序的链表并将其作为一个已排序的链表返回,分析并描述其复杂度 class Solution{ public: struct cmp{ bool operator() (const ListNode *a, const Lis 阅读全文
posted @ 2020-10-16 09:38 威威后花园 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-10-15 17:27 威威后花园 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-10-14 09:42 威威后花园 阅读(104) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页