
leetcode/lnitcode/Solve Progra
文章平均质量分 75
做只幽默的程序袁
IT理工男
展开
-
简单的条件语句应用
今天晚上的程序题比较简单,是Hankranker上的算法题目主要是让对于输入的一大串指令操作集合做处理比如给你一系列的输入,这些输入都是对于一个列表的增删改查操作最后让你遇到print语句就输出程序很简单,但是从简单的做起,不能眼高手低我的思考方法也不是一帆风顺的,刚开始我觉得按照一个for循环,每次循环体内直接在输入后就操作了,这是不对的,因为当在循环体内部输入一条指令的时候,我们要是提前操作了...原创 2018-02-08 20:43:04 · 974 阅读 · 0 评论 -
Leetcode题目之删除重复元素(非有序列表)
今天做的这道题目是删除列表中的重复元素,是同之前的有序列表的题目不太一样,但是思路差不多,因此先看下题目:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for anot...原创 2019-04-01 20:30:28 · 453 阅读 · 0 评论 -
leetcode题目之最长回文子串
关于字符串的问题,无论是回文子串,还是说最大不重复子串,或者其他类型的子串,对于这种关于子串的问题一直都比较头疼,尤其是今天碰到的这个题目,感觉想了真的很久,尤其是对于python中的字符切片问题,总是考虑到index的范围问题,就很是苦恼。闲话少说,先来看题目:Given a string s, find the longest palindromic substring in s. Y...原创 2019-03-22 16:44:46 · 237 阅读 · 0 评论 -
leetcode题目之ZigZag
先让我哭会儿。。。这道题让我自闭了,发现自己逻辑思维能力好差,因为我从看到这道题再到想这道题,然后再开始码代码,然后再运行、调试,真的心累,然后也不知道到底哪儿出了问题,但是,程序袁挺过来了,最后验证自己的逻辑是正确的,开心!(没见过世面的样子。。。)看题如下:The string "PAYPALISHIRING" is written in a zigzag pattern on a...原创 2019-03-25 23:32:41 · 417 阅读 · 0 评论 -
Leetcode题目之两个数组的中位数
先来看题目描述:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume n...原创 2019-03-16 15:12:19 · 223 阅读 · 0 评论 -
Leetcode题目之最长无重复子串
先来看问题描述:Given a string, find the length of the longest substring without repeating characters.给一个字符串,找出来这个字符串中最长的没有重复字符的子串Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "ab...原创 2019-03-16 15:06:38 · 206 阅读 · 0 评论 -
Leetcode题目之求罗马数字字符串转换为阿拉伯数字的值的结果
题目其实挺长,主要说了关于罗马数字字符对应于阿拉伯数字的知识,另外介绍了如何将一个字符串转换为数字的计算方法,见下面的描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5...原创 2018-12-12 02:17:13 · 309 阅读 · 0 评论 -
Leetcode题目之求字符串中子串位置指针索引
首先来看下这个题目的问题:简言之就是要求一个字符串中,某一个子串它的下标,如果有,则返回这个子串首次出现的下标,如果没有,就返回-1,下面是原题:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack....原创 2018-12-12 01:13:19 · 682 阅读 · 0 评论 -
leetcode题目之计算两个二进制的值的和
这道题目有点简单,完全是占了python的便宜,因为都是使用函数完成的。先看问题描述:Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:...原创 2018-12-15 01:24:06 · 277 阅读 · 0 评论 -
leetcode题目之数组加1问题
先看题目:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each ...原创 2018-12-15 01:03:03 · 555 阅读 · 0 评论 -
leetcode题目之求数值下标问题
这道题意思是给出一个有序的列表,里面的元素类型都是整型,然后给定一个数字,如果这个数字在这个列表中出现了,那就返回这个数字在这个列表中的下标(从0开始),如果这个数字没有出现,那就返回插入这个数字到这个列表中,此时这个数字应该有的下标值。看下题目描述:Given a sorted array and a target value, return the index if the targe...原创 2018-12-13 03:39:13 · 406 阅读 · 0 评论 -
leetcode题目之括号匹配问题
关于括号匹配问题,提到这个问题就会想到数据结构栈,关于括号匹配大家也都是熟悉不过了,不过今天刷起这道题,还是让我花了一些时间去回忆这里面的一些细节,尤其是用python去复现的时候。首先看一下问题描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the...原创 2018-12-13 02:07:29 · 15622 阅读 · 0 评论 -
简单的哈希函数求值
今天晚上的程序依然比较简单,是将一个元组哈希函数的值输出不过这个元组的值根据输入而定,但是我没有采取循环的方法,先定义一个列表,再把元素依次添加进这个列表中,而是直接用了一个类型转换+切片的方式将输入的字符串切片后然后转换成整型,接着再强制类型转换成列表类型。哈希函数数据结构中有讲过,hash函数,一种将任意的输入映射成固定长度的输出,是一种压缩映射。具体的原理我后面再研究,哈哈!下面是我的程序:...原创 2018-02-09 22:22:51 · 869 阅读 · 0 评论 -
Leetcode题目之删除有序列表中的重复元素
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2019-03-29 13:45:49 · 493 阅读 · 0 评论