Leetcode 题解(c/c++/python)
使用三种语言完成Leetcode题目,并附上解题思路
bcyan
这个作者很懒,什么都没留下…
展开
-
203. Remove Linked List Elements
Remove all elements from a linked list of integers that have valueval. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 /** * Definition for ...原创 2020-05-05 16:02:18 · 105 阅读 · 0 评论 -
7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with...原创 2019-12-16 14:00:42 · 82 阅读 · 0 评论 -
5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Exampl...原创 2019-12-13 18:34:39 · 87 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: In...原创 2019-12-13 14:32:27 · 71 阅读 · 0 评论 -
2. Add Two Numbers
You 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 and return i...原创 2019-11-07 17:05:14 · 66 阅读 · 0 评论 -
1. Two sum
题目描述 给定一个整型数组,要求返回两个数的下标,使得两数之和等于给定的目标值,要求同一个下标不能使用两次。 数据保证有且仅有一组解。 样例 给定数组 nums = [2, 7, 11, 15],以及目标值 target = 9, 由于 nums[0] + nums[1] = 2 + 7 = 9, 所以 return [0, 1]. 算法1: (暴力枚举)O(n^2) 使用两个循环实...原创 2019-11-06 16:44:03 · 118 阅读 · 0 评论