04 2019 档案

该文被密码保护。
posted @ 2019-04-30 22:28 三年一梦 编辑
摘要:1. 原始题目 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", num2 = "456" 阅读全文
posted @ 2019-04-30 11:51 三年一梦 阅读(173) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。 示例: 2 阅读全文
posted @ 2019-04-29 13:12 三年一梦 阅读(1287) 评论(0) 推荐(1) 编辑
摘要:315. Count of Smaller Numbers After Self 计算右侧小于当前元素的个数(逆序数) 图源:慕课网 1. 原始题目 计算右侧小于当前元素的个数 给定一个整数数组 nums,按要求返回一个新数组 counts。数组 counts 有该性质: counts[i] 的值是 阅读全文
posted @ 2019-04-29 10:52 三年一梦 阅读(873) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 示例 2: 说明: 你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。 2. 思路 可以利用优先队列存储元素,然后分别出对,每次出对都是 阅读全文
posted @ 2019-04-29 09:35 三年一梦 阅读(238) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-04-28 19:59 三年一梦 阅读(27) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-04-27 19:17 三年一梦 阅读(14) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-04-27 14:57 三年一梦 阅读(29) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-04-26 12:08 三年一梦 阅读(47) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-04-26 09:36 三年一梦 阅读(23) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个未排序的整数数组,找出其中没有出现的最小的正整数。 示例 1: 示例 2: 示例 3: 2. 思路 交换法 第一遍遍历:对于数组每个>=1的元素(正整数)且大小小于数组长度的元素都要交换位置以确保其在数组中的位置正确。 第二遍遍历:如果当前元素的位置不正确则返回该元素大小+1 阅读全文
posted @ 2019-04-23 12:03 三年一梦 阅读(219) 评论(0) 推荐(0) 编辑
摘要:本文分为两部分:第一部分转载一篇很好的递归总结博文,第二部分是我自己对递归思想的理解以及几道编程题。 第一部分 3道题彻底搞定:套路解决递归问题(转载) 前言 相信不少同学和我一样,在刚学完数据结构后开始刷算法题时,遇到递归的问题总是很头疼,而一看解答,却发现大佬们几行递归代码就优雅的解决了问题。从 阅读全文
posted @ 2019-04-22 10:50 三年一梦 阅读(35970) 评论(4) 推荐(4) 编辑
摘要:1.BrokenPipeError 执行以下命令时: 报错:BrokenPipeError: [Errno 32] Broken pipe 错误原因:子进程原因 On Windows the subprocesses will import (i.e. execute) the main modul 阅读全文
posted @ 2019-04-20 15:37 三年一梦 阅读(1223) 评论(0) 推荐(0) 编辑
摘要:目前在学习论文SphereFace:Deep Hypersphere Embedding for Face Recognition.将一些预备知识总结与本文。 一. 数据集部分 1.CASIA-WebFace 来源:Learning face representation from scratch 阅读全文
posted @ 2019-04-20 15:05 三年一梦 阅读(1479) 评论(1) 推荐(0) 编辑
摘要:1. 原始题目 报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下: 1 被读作 "one 1" ("一个一") , 即 11。11 被读作 "two 1s" ("两个一"), 即 21。21 被读作 "one 2", "one 1" ("一个二" , "一个一") , 阅读全文
posted @ 2019-04-20 12:03 三年一梦 阅读(365) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 判断一个 9x9 的数独是否有效。只需要根据以下规则,验证已经填入的数字是否有效即可。 上图是一个部分填充的有效的数独。 数独部分空格内已填入了数字,空白格用 '.' 表示。 示例 1: 示例 2: 说明: 一个有效的数独(部分已被填充)不一定是可解的。 只需要根据以上规则,验证已经 阅读全文
posted @ 2019-04-20 11:15 三年一梦 阅读(137) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 示例 1: 示例 2: 示例 3: 示例 4: 2. 思路 还是考二分法。对于没有重复元素的排序序列,二分法如果找到该元素则返回。找 阅读全文
posted @ 2019-04-20 10:24 三年一梦 阅读(204) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 你的算法时间复杂度必须是 O(log n) 级别。 如果数组中不存在目标值,返回 [-1, -1]。 示例 1: 示例 2: 2. 思路 既然是有序数组,可以2分法。如 阅读全文
posted @ 2019-04-20 10:00 三年一梦 阅读(397) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 必须原地修改,只允许使用额外常数空间。 以下是一些例子,输入位于左侧列,其相应输出位于右侧列。1,2,3 → 1,3,23, 阅读全文
posted @ 2019-04-19 21:00 三年一梦 阅读(199) 评论(0) 推荐(0) 编辑
摘要:好久没有在win下写东西了。导致又一次踩到了坑里。 1. PIL库读图,转为numpy:np.array() 2. opencv读入的图像是BGR格式,转为RGB:img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 3. opencv保存时,路径不能是中文!!!否则 阅读全文
posted @ 2019-04-19 17:10 三年一梦 阅读(554) 评论(0) 推荐(0) 编辑
摘要:1. torch.renorm(input, p, dim, maxnorm, out=None) → Tensor Returns a tensor where each sub-tensor of input along dimension dim is normalized such that 阅读全文
posted @ 2019-04-17 23:03 三年一梦 阅读(1884) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。 示例: 2. 解题 思路1. 优先队列。即自动排序的队列。 将所有链表结点依次进队,此时结点已排好序,再分别出队组成新链表即可。 注:python3的优先队列: 有了优先队列,这个题就是easy了: 思路2.DP 阅读全文
posted @ 2019-04-10 18:13 三年一梦 阅读(506) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 示例: 说明:尽管上面的答案是按字典序排列的,但是你可以任意选择答案输出的顺序。 2. 解法 这题明显可以用递归。但是不太好理解,参考了Leet 阅读全文
posted @ 2019-04-10 15:40 三年一梦 阅读(192) 评论(0) 推荐(1) 编辑
摘要:1. 原始题目 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。 2. 分析 本题是最近的三数之和,与15题三数之和很类似,不同之处有这么几点: 1)三数之和要求 阅读全文
posted @ 2019-04-10 14:58 三年一梦 阅读(111) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。 注意:答案中不可以包含重复的三元组。 例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4], 满足 阅读全文
posted @ 2019-04-10 11:42 三年一梦 阅读(168) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 示例 2: 说明: 所有输入只包含小写字母 a-z 。 2. 解法 思路:任选一个串作为参考串,然后以该串前几部分依次作为模板和后面的串比较,如果不同则返回,相同则比较更长的子串。 阅读全文
posted @ 2019-04-09 22:09 三年一梦 阅读(262) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 例如, 罗马数字 2 写做 II ,即为两个并列的 1。12 写做 XII ,即为 X + II 。 27 写做 XXVII, 即为 XX + V + II 。 通常情况下,罗马数字中小的数字在大的数字的右边。但也存 阅读全文
posted @ 2019-04-09 21:43 三年一梦 阅读(139) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 例如, 罗马数字 2 写做 II ,即为两个并列的 1。12 写做 XII ,即为 X + II 。 27 写做 XXVII, 即为 XX + V + II 。 通常情况下,罗马数字中小的数字在大的数字的右边。但也存 阅读全文
posted @ 2019-04-09 21:26 三年一梦 阅读(163) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器,且 n 的 阅读全文
posted @ 2019-04-09 20:35 三年一梦 阅读(229) 评论(0) 推荐(0) 编辑
摘要:首先,这是一道比较蠢的题目,没有太多意思。 1. 原始题目 请你来实现一个 atoi 函数,使其能将字符串转换成整数。 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整 阅读全文
posted @ 2019-04-09 19:28 三年一梦 阅读(825) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 注意: 假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为 [ 阅读全文
posted @ 2019-04-09 17:30 三年一梦 阅读(159) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 示例 2: 2. 我的解法 比较经典的问题,寻找最长回文子串。Leetcode里提供了多种解法。我采用最直观的解法:中心扩展法。 思路是每次以当前元素为中心向两边扩展,直到遇到不同元 阅读全文
posted @ 2019-04-09 15:05 三年一梦 阅读(598) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 示例 2: 示例 3: 2. 我的解法 每次都寻找不同的字符放到空表里,直到有相同的出现。这时指针指向下一位进行下一轮搜索。 我的时间复杂度比较高,新建立许多变量,导致空间占用较多。Leetcode上另一个 阅读全文
posted @ 2019-04-09 10:39 三年一梦 阅读(323) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 We are given head, the head node of a linked list containing unique integer values. We are also given the list G, a subset of the values in th 阅读全文
posted @ 2019-04-08 09:12 三年一梦 阅读(181) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their node 阅读全文
posted @ 2019-04-07 11:43 三年一梦 阅读(147) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 2. 题目理解 将m至n的链表反转。注意下标这里在链表中实际上是m-1至 阅读全文
posted @ 2019-04-07 11:02 三年一梦 阅读(247) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should prese 阅读全文
posted @ 2019-04-07 09:50 三年一梦 阅读(382) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, 阅读全文
posted @ 2019-04-06 11:53 三年一梦 阅读(109) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a singly linked list, determine if it is a palindrome. Example 1: Example 2: 2. 题目理解 判断给定链表是否为回文。即正反节点数字一样。例如1234321,无论正反都是这个。就是对称。 坑:空链 阅读全文
posted @ 2019-04-06 10:47 三年一梦 阅读(169) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents 阅读全文
posted @ 2019-04-06 10:09 三年一梦 阅读(121) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: beg 阅读全文
posted @ 2019-04-05 19:44 三年一梦 阅读(255) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the seco 阅读全文
posted @ 2019-04-05 16:34 三年一梦 阅读(437) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: 2. 题目理解 给定一个排序链表,删除所有重复的元素,使得 阅读全文
posted @ 2019-04-05 11:47 三年一梦 阅读(237) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly link 阅读全文
posted @ 2019-04-05 10:48 三年一梦 阅读(213) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 2. 题目理解 给定一个链表,旋转链表,将链表每个节点向右移动  阅读全文
posted @ 2019-04-04 22:39 三年一梦 阅读(131) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself m 阅读全文
posted @ 2019-04-04 22:05 三年一梦 阅读(124) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Given a linked list, remove the n-th node from the end of list and return its head. Example: 2. 题目理解 删除列表中倒数第n个数 注意:空列表,和n大于链表长度的情况 3. 解题 改题和剑 阅读全文
posted @ 2019-04-04 20:50 三年一梦 阅读(168) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their node 阅读全文
posted @ 2019-04-04 17:00 三年一梦 阅读(353) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Reverse a singly linked list. Example: 2. 题目理解 反转一个单链表 注意:空链表的处理,单个结点的处理 3. 解法 因为在反向指向结点的时候容易导致链表出现断裂,所以需3个结点保存当前结点,当前结点之前,之后的结点。 4. 验证结果 1 1 阅读全文
posted @ 2019-04-04 15:32 三年一梦 阅读(137) 评论(0) 推荐(0) 编辑
摘要:1. 原始题目 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 阅读全文
posted @ 2019-04-04 14:51 三年一梦 阅读(540) 评论(1) 推荐(0) 编辑
摘要:1. 原始题目 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers fo 阅读全文
posted @ 2019-04-01 11:50 三年一梦 阅读(179) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示