![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
刷题
文章平均质量分 71
小杨快没头发了
去年开始转入计算机专业领域,还有很多东西要学。
最近开始搭建自己的个人博客,将会不断把日常刷题题解以及以往开发项目及学习笔记上传,持续更新。希望感兴趣的可以关注一下~
展开
-
leetcode-20. Valid Parentheses 有效的括号 (C) 华为一面
leetcode 20. Valid ParenthesesGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets.Open brackets原创 2021-05-08 14:57:37 · 219 阅读 · 0 评论 -
力扣 206 -翻转链表
反转链表 206 4/20/2020Reverse Linked List - Easy地址: https://leetcode.com/problems/reverse-linked-list/题目描述Given the head of a singly linked list, reverse the list, and return the reversed list.Example 1:Input: head = [1,2,3,4,5]Output: [5,4,3,2,1]原创 2021-04-20 19:49:43 · 109 阅读 · 0 评论 -
力扣 62. Unique Paths-不同路径-二维方向上到达某点的路径数(Python版本)
力扣 62. Unique Paths-不同路径(Python版本)题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corne原创 2021-04-04 20:42:15 · 176 阅读 · 1 评论 -
力扣66. Plus One - 加一 (Python版本,两解题思路)
力扣66. 加一 (Python版本,两解题思路)题目描述Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element in the arra原创 2021-04-03 14:26:03 · 123 阅读 · 0 评论 -
力扣1. Two Sum 两数之和 (python)
Leetcode 1. Two Sum 两数之和 (python)题目Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same ele原创 2021-04-01 11:28:36 · 233 阅读 · 1 评论 -
力扣 160 - Intersection of Two Linked Lists. (相交链表) Python双指针
力扣 160 - Intersection of Two Linked Lists. (相交链表) Python双指针https://leetcode.com/problems/intersection-of-two-linked-lists/Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lis原创 2021-04-01 01:03:13 · 213 阅读 · 1 评论 -
【求问帖】数组相邻元素最大公约数不断替换直到所有元素为1 - 最少步骤数
给一组序列,求其中相邻两个元素之间的最大公约数。一直不停求下去直到所有元素被替换为1. 如果实在不能全部替换,则返回-1输入的第一行为元素个数 n ,第二行为序列arrExample1Input:44 1 3 5Output3Example2:Input:510 20 30 40 50Output:-1上面的题目是今天模拟考的一道算法题,限时半小时。思路:很明显如果序列里出现1,这个序列就一定能全部转为1,因为1和任何数的公约数都为1。那么最先设立的一个.原创 2021-03-30 15:18:48 · 392 阅读 · 0 评论 -
动态规划 复习 - 组成部分和步骤
简介本文为复习动态规划的笔记,在UCLA CS180的笔记基础上增添了B站up主 七章算法的教学视频自学笔记内容DP 的定义是:Consider a problem of size n• Split the problem into smaller parts 把问题拆分为多个子问题• The solution of the original problem can be iteratively computed based on the solutions of subproblems原创 2021-03-29 14:13:48 · 171 阅读 · 0 评论 -
字节笔试 - 寿司最大价格 - 动态规划 - 数组不相邻数之和最大值
寿司题 - 数组不相邻数之和最大值此题来自于朋友在字节的笔试, 同类题目可见leetcode 198题 House Robber.给你一堆寿司 不能选相邻的盘子 然后要选出价格加起来最高的那些 print价格举例 [9 1 4 3] 输出13如果是[9 1 3 2 5] 输出17从题目知道这题本质是给一组数组,求数组里不相邻元素的最大值和,也就是说,求最优解。思路最优解题目使用DP。第一步是 **确定状态 **。假设有10碟寿司,价格如下寿司序列[0][1][2][原创 2021-03-29 13:53:35 · 325 阅读 · 3 评论 -
刷题 - 字符串类型题目(不定时更新)
刷题 - 字符串类型题目(不定时更新)1. 字符串最后一个单词的长度 (Python- split())x = input()y = x.split()length = len(y[-1]) # -1 最后一个单词print(length)要点:split() 对字符串进行切片(根据空格符包括空格换行(\n)、制表符(\t)等)。如果参数num有指定值,则分割num+1个子字符串参数str – 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。num – 分割次原创 2021-03-28 13:58:12 · 602 阅读 · 0 评论