判断链表是否为回文链表leetcode-LeetCode:我在leetcode上的一些代码

  • c3_726084
    了解作者
  • 179.8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-08 04:33
    上传日期
判断链表是否为回文链表 leetcode 力码 我在 leetcode 上的一些代码。 这里将描述一些问题。 标签=容易 001.二和 给定一个整数数组,返回两个数字的索引,使它们相加为特定目标。 您可以假设每个输入都只有一个解决方案,并且您不能两次使用相同的元素。 例子: 给定 nums = [2, 7, 11, 15], target = 9, 因为 nums[0] + nums[1] = 2 + 7 = 9, 返回 [0, 1]。 007. 反转整数 给定一个 32 位有符号整数,反转整数的数字。 示例 1: 输入:123 输出:321 示例 2: 输入:-123 输出:-321 示例 3: 输入:120 输出:21 笔记: 假设我们正在处理一个只能保存 32 位有符号整数范围内的整数的环境。 出于此问题的目的,假设您的函数在反转整数溢出时返回 0。 009. 回文数 判断一个整数是否是回文。 在没有额外空间的情况下执行此操作。 013.罗马到整数 给定一个罗马数字,将其转换为整数。 输入保证在 1 到 3999 的范围内。 命中 1: I - 1 V - 5 X - 10 L
LeetCode-master.zip
  • LeetCode-master
  • Hard
  • README_hard.md
    1.5KB
  • rainwatertrap.png
    7.7KB
  • iNo041.py
    398B
  • iNo042.py
    686B
  • pic
  • 3`[)G)XIN)F{W@@Z(MGWBSR.png
    87.8KB
  • rainwatertrap.png
    7.7KB
  • }B9BO}$}MER8DH{)_(RDP{Q.png
    49.5KB
  • Contest
  • iNo876.py
    842B
  • contest096.md
    4.5KB
  • iNo887.py
    568B
  • iNo884.py
    798B
  • iNo878.py
    448B
  • iNo877.py
    1.7KB
  • iNo885.py
    234B
  • contest095.md
    3.9KB
  • Medium
  • iNo031.py
    2.6KB
  • iNo002.py
    1.4KB
  • iNo034.py
    431B
  • iNo47.py
    1.7KB
  • iNo081.cpp
    267B
  • iNo012.py
    1KB
  • iNo022.py
    1.8KB
  • iNo019.py
    2.3KB
  • iNo036.py
    2.5KB
  • iNo039.py
    931B
  • iNo050.py
    161B
  • iNo017.py
    1KB
  • iNo003.py
    393B
  • iNo006.py
    839B
  • iNo029.py
    1.6KB
  • iNo040.py
    968B
  • iNo033.py
    438B
  • iNo008.py
    774B
  • iNo046.py
    1.6KB
  • iNo049.py
    1.9KB
  • iNo043.py
    2.1KB
  • iNo048.py
    658B
  • README_medium.md
    15.8KB
  • iNo005.py
    2.1KB
  • iNo024.py
    1.4KB
  • iNo013
    830B
  • iNo069
    164B
  • iNo021
    1.3KB
  • iNo088
    1.1KB
  • iNo007
    472B
  • iNo014
    749B
  • iNo104.py
    600B
  • iNo027
    344B
  • iNo100
    997B
  • README.md
    11.2KB
  • iNo038
    1.5KB
  • iNo035
    345B
  • iNo009
    601B
  • iNo066
    1.6KB
  • iNo001
    463B
  • iNo020
    809B
  • iNo026
    355B
  • iNo058
    236B
  • iNo067
    915B
  • iNo070
    308B
  • iNo083
    569B
  • iNo053
    378B
  • iNo107.py
    993B
  • iNo028
    436B
内容介绍
# LeetCode Some codes of mine on the leetcode. Here will be a description of some questions. ## tag=easy ### 001. Two Sum 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 use the same element twice. Example:<br> Given nums = [2, 7, 11, 15], target = 9,<br> Because nums[0] + nums[1] = 2 + 7 = 9,<br> return [0, 1].<br> ### 007. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1:<br> Input: 123 Output: 321 <br> Example 2:<br> Input: -123 Output: -321 <br> Example 3:<br> Input: 120 Output: 21 <br> Note:<br> Assume we are dealing with an environment which could only hold integers within the 32-bit signed integer range. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.<br> ### 009. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space.<br> ### 013. Roman to Integer Given a roman numeral, convert it to an integer.<br> Input is guaranteed to be within the range from 1 to 3999.<br> Hit 1:<br> I - 1 V - 5 X - 10 L - 50 C - 100 D - 500 M - 1000<br> Hit 2:<br> Rules:<br> * If I comes before V or X, subtract 1 eg: IV = 4 and IX = 9<br> * If X comes before L or C, subtract 10 eg: XL = 40 and XC = 90<br> * If C comes before D or M, subtract 100 eg: CD = 400 and CM = 900<br>   ### 014. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.<br>   ### 020. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.<br> ### 021. Merge Two Sorted Lists 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.<br> Example:<br> Input: 1->2->4, 1->3->4<br> Output: 1->1->2->3->4->4<br> ### 026. Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.<br> Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.<br> Example 1:<br> Given nums = [1,1,2],<br> Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively.<br> It doesn't matter what you leave beyond the returned length.<br> Example 2:<br> Given nums = [0,0,1,1,1,2,2,3,3,4],<br> Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively.<br> It doesn't matter what values are set beyond the returned length.<br> Clarification:<br> Confused why the returned value is an integer but your answer is an array?<br> Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.<br> Internally you can think of this:<br> // nums is passed in by reference. (i.e., without making a copy)<br> int len = removeDuplicates(nums);<br> // any modification to nums in your function would be known by the caller.<br> // using the length returned by your function, it prints the first len elements.<br> for (int i = 0; i < len; i++) {<br> print(nums[i]);<br> }<br> ### 027. Remove Element Given an array nums and a value val, remove all instances of that value in-place and return the new length.<br> Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.<br> The order of elements can be changed. It doesn't matter what you leave beyond the new length.<br> Example 1:<br> Given nums = [3,2,2,3], val = 3,<br> Your function should return length = 2, with the first two elements of nums being 2.<br> It doesn't matter what you leave beyond the returned length.<br> Example 2:<br> Given nums = [0,1,2,2,3,0,4,2], val = 2,<br> Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.<br> Note that the order of those five elements can be arbitrary.<br> It doesn't matter what values are set beyond the returned length.<br> Clarification:<br> Confused why the returned value is an integer but your answer is an array?<br> Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.<br> Internally you can think of this:<br> // nums is passed in by reference. (i.e., without making a copy)<br> int len = removeElement(nums, val);<br> // any modification to nums in your function would be known by the caller.<br> // using the length returned by your function, it prints the first len elements.<br> for (int i = 0; i < len; i++) {<br> print(nums[i]);<br> }<br> ### 028. Implement strStr() Implement strStr().<br> Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.<br> Example 1:<br> Input: haystack = "hello", needle = "ll"<br> Output: 2<br> Example 2:<br> Input: haystack = "aaaaa", needle = "bba"<br> Output: -1<br> Clarification:<br> What should we return when needle is an empty string? This is a great question to ask during an interview.<br> For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().<br> ### 035. Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.<br> You may assume no duplicates in the array.<br> Example 1:<br> Input: [1,3,5,6], 5<br> Output: 2<br> Example 2:<br> Input: [1,3,5,6], 2<br> Output: 1<br> Example 3:<br> Input: [1,3,5,6], 7<br> Output: 4<br> Example 4:<br> Input: [1,3,5,6], 0<br> Output: 0<br> ### 038. Count and Say The count-and-say sequence is the sequence of integers with the first five terms as following:<br> 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11.<br> 11 is read off as "two 1s" or 21.<br> 21 is read off as "one 2, then one 1" or 1211.<br> Given an integer n, generate the nth term of the count-and-say sequence.<br> Note: Each term of the sequence of integers will be represented as a string.<br> Example 1:<br> Input: 1<br> Output: "1"<br> Example 2:<br> Input: 4<br> Output: "1211"<br> ### 053. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.<br> Example:<br> Input: [-2,1,-3,4,-1,2,1,-5,4],<br> Output: 6<br> Explanation: [4,-1,2,1] has the largest sum = 6.<br> Follow up:<br> If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.<br> ### 058. Length of Last Word Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.<br> If the last word does not exist, return 0.<br> Note: A word is defined as a character sequence consists of non-space characters only.<br> Example:<br> Input: "Hello World"<br> Output: 5<br> ### 066. Plus One Given a non-empty array of digits representing a non-negative integer, plus one to the integer.<br> The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.<br> You may assume the integer does not contain any leading zero, except the number 0 itself.<br> Example 1:<br> Input: [1,2,3]<br> Output: [1,2,4]<br> Explanation: The array represents the integer 123.<br> Example 2:<br> Input: [4,3,2,1]<br> Output: [4,3,2,2]<br> Explanation: The array represents the integer 4321.<br> ### 067. Add Binary Given two binary strings, return
评论
    相关推荐
    • 判断链表是否为回文链表leetcode-LeetCode:力码
      判断链表是否为回文链表 leetcode LeetCode 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数 给定一个 32 位有符号整数,将整数中的数字进行反转 判断一个整数是否是回文数。回文数是指正序(从左向右...
    • 判断链表是否为回文链表leetcode-Leetcode:leetcode的解决方案
      判断链表是否为回文链表 leetcode 力码 leetcode 的解决方案。 二和。 给定一个整数数组,返回两个数字的索引,使它们相加为特定目标。 您可以假设每个输入都只有一个解决方案,并且您不能两次使用相同的元素。 例子...
    • 判断链表是否为回文链表leetcode-Leetcode:力码
      判断链表是否为回文链表 leetcode 力码 我的 leetcode 问题解决方案。 二和 给定一个整数数组,返回两个数字的索引,使它们相加为特定目标。 您可以假设每个输入都只有一个解决方案,并且您不能两次使用相同的元素。...
    • 判断链表是否为回文链表leetcode-LeetCode:leetcode日常乐趣
      判断链表是否为回文链表 leetcode LeetCode leetcode dayly fun koltin解leetcode 可能时间空间复杂度不是最优的,但是能AC android开发刷题练练手 先easy后medium 最后才考虑hard 主要是锻炼开拓思维和灵活运用各种...
    • 判断链表是否为回文链表leetcode-LeetCode:LeetCode刷题
      判断链表是否为回文链表 leetcode LeetCode 做题指南 记录一下做过的LeetCode编程题,每道题有解题思路+代码,方便自己和他人学习 ArrayDemo: 1.ContainsDuplicate 存在重复:给定一个整数数组,判断是否存在重复...
    • 判断链表是否为回文链表leetcode-lintCode:代码
      判断链表是否为回文链表 leetcode LeetCode 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数 给定一个 32 位有符号整数,将整数中的数字进行反转 判断一个整数是否是回文数。回文数是指正序(从左向右...
    • 判断链表是否为回文链表leetcode-CTCI:CTCI
      判断链表是否为回文链表 leetcode CTCI #Leetcode 自交 移动零将数组中的零移向末尾而不改变元素的原始位置 反转树 旋转树中的所有节点,使左节点变为右节点,右节点变为左节点。 从 LL 中删除节点 从 LL 中删除一个...
    • 判断链表是否为回文链表leetcode-LeetCode:我对LeetCode问题的解决方案
      判断链表是否为回文链表 leetcode 力码 我对 LeetCode 问题的解决方案。 每个文件都有一个问题陈述、我的解决方案和几个测试,偶尔还有我对如何实现解决方案的推理。 1-9 两个总和- 给定一个整数数组,返回两个数字...
    • 判断链表是否为回文链表leetcode-DailyCodingProblem:日常编码问题
      判断链表是否为回文链表 leetcode /** Leetcode 样题练习 */ 无重复字符的最长子串 反转单链表。 你正在爬楼梯。 需要n步才能到达顶部。 每次您可以爬 1 步或 2 步。 你可以通过多少种不同的方式登上顶峰? (注意:...
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等