随便刷刷题啦
文章平均质量分 51
wayne17
这个作者很懒,什么都没留下…
展开
-
leetcode 1024 马尔科夫活动暴力代码
leetcode 1024 马尔可夫活动暴力代码原创 2022-10-18 23:23:04 · 725 阅读 · 1 评论 -
Leetcode1:Two Sum(两数之和)
Description:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not ...原创 2019-03-08 12:31:29 · 188 阅读 · 0 评论 -
Leetcode 2 :Add Two Numbers(两数相加(链表))(大数相加)
DesciptionYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers ...原创 2019-03-19 18:40:59 · 324 阅读 · 0 评论 -
Leetcode 3:Longest Substring Without Repeating Characters(最长不重复子串)
DescriptionGiven a string, find the length of the longest substring without repeating characters.给你一个字符串,求出其最长不重复字串的长度。ExampleInput: "abcabcbb"Output: 3 Explanation: The answer is "abc", with ...原创 2019-03-20 13:17:20 · 132 阅读 · 0 评论 -
Leetcode 4:Median of Two Sorted Arrays(寻找两个有序数组的中位数)
DescriptionThere 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-24 17:28:50 · 185 阅读 · 0 评论 -
Leetcode 6:ZigZag Conversion
原题链接:ZigZag Conversion 一开始的思路是根据所给字符串及 Z 行数计算出末元素所在的行列数,进而用二维数组来计算blabla…但算到后期发现不用这么复杂。。。原理如下图对于给定的 z 型串,我们取 2*numRows-2为一个周期(除数),以字符串 s 的长度为被除数;z 型串的第一行元素所在位置除以除数,余数皆为 1,第二行元素所在位置除以除数余数,余数为 0 或 ...原创 2020-03-27 20:46:55 · 174 阅读 · 0 评论 -
Leetcode 7:Reverse Integer(整数反转)
Description:Given a 32-bit signed integer, reverse digits of an integer.给出一个 32 位的有符号整数,将这个整数每位上的数字进行前后反转。Note:Assume we are dealing with an environment which could only store integers within t...原创 2020-03-18 21:11:34 · 187 阅读 · 0 评论 -
Leetcode 8:String to Integer (atoi)
Description: 请你来实现一个 atoi 函数,使其能将字符串转换成整数。 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。 该字符串除了有效的整数部分之...原创 2020-03-24 09:50:14 · 113 阅读 · 0 评论 -
Leetcode 9:Palindrome Number
原题链接:Palindrome Number 乍一看,这题挺简单,直接将 int 转化为 string 处理,几行代码完事class Solution { public: bool isPalindrome(int x) { string s = to_string(x); string s1 = s; std:...原创 2020-04-22 11:01:56 · 153 阅读 · 0 评论 -
Single Number(leetCode 136)
题目描述给定一个非空整数数组,除了某个元素出现一次之外,其余每个元素均出现两次。找出那个只出现了一次的元素。Example 1:Input: [2,2,1]Output: 1Example 2:Input: [4,1,2,1,2]Output: 4Solution 1:自己瞎写的一个解法,用两个下标 i,ji,ji,j 同时对 v[ ] 进行遍历,iii 从0开始, jj...原创 2019-01-27 12:11:09 · 210 阅读 · 0 评论