
leetcode
Jie Ou
学习
展开
-
LeetCode 3Sum python
from collections import defaultdictclass Solution: def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ nums.sort() d=...原创 2018-10-31 20:39:08 · 244 阅读 · 0 评论 -
【LeetCode】 4Sum 【Python C++】
题目:从给定的一堆数字中找出 所有 4个数之和=taget的组合。组合与组合之间不得重复Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique qua...原创 2018-11-14 11:25:40 · 126 阅读 · 0 评论 -
【LeetCode】 Remove Nth Node From End of List 【python C++】做法详解
题目,从listnode 中删除倒数第n个点Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the sec...原创 2018-11-15 21:13:11 · 145 阅读 · 0 评论 -
【LeetCode】 11. Container With Most Water 【Python || C++】双语言实现
题目(来自leetcode网站):这个题目的意思是,给你排好一堆柱子,找出容量最大的两根;最基本的想法是用两个for循环,但是这样太慢了;一开始没想出来,后来看了别人的想法。。。Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n ve...原创 2018-11-05 15:51:35 · 247 阅读 · 0 评论 -
【LeetCode】 Longest Common Prefix 【Python || C++】
题目:最长的前缀公共子字符串Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow"...原创 2018-11-07 17:43:14 · 149 阅读 · 0 评论 -
【LeetCode】String to Integer (atoi) 【Python || C++】
题目:主要是实现C/C++的一个库函数的功能,把字符串转换成intImplement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace charac...原创 2018-11-07 10:57:35 · 182 阅读 · 0 评论 -
【LeetCode】Palindrome Number 【Python || C++】 双语言实现
题目(来自leetcode网站):python3 三种C++一种Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExam...原创 2018-11-04 19:22:43 · 280 阅读 · 0 评论 -
【LeetCode】 Longest Palindromic Substring 【Python C++】双语言实现
题目(来源leetcode):题目的意思就是从给定的字符串中找出一个最长的 对称 字符串这道题,我的代码感觉写的贼烂,求大佬指点!Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:...原创 2018-11-02 17:40:26 · 128 阅读 · 0 评论 -
【LeetCode】Longest Palindromic Substring【Python || C++】双语言实现
题目(来自leetcode网站):题目的意思是把 输入的整数倒叙输出,不改变符号,且需要对整数的范围进行判断;Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321E...原创 2018-11-04 15:04:12 · 368 阅读 · 0 评论 -
【LeetCode】 ZigZag Conversion 【Python || C++】双语言实现
题目(来自leetcode网站):实现了python版本实现了C++版本题目含义为,将输入字符串 首先根据numRows大小进行 列的 Z 字形 排列 后,把每一行直接拼接起来输出;The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you ...原创 2018-11-04 14:02:51 · 503 阅读 · 0 评论 -
LeetCode Median of Two Sorted Arrays 【python C++】实现
题目(来自leetcode网站):实现方式采用了 python3 以及 C++本次题目的要求为:从给定的两个已排序的nums1和nums2向量中,找出整个域内排序后的 中位数的值。如果大佬们有比较好的 方法,希望能够指点下小弟^_^!There are two sorted arrays nums1 and nums2 of size m and n respectively....原创 2018-11-01 16:07:11 · 202 阅读 · 0 评论 -
LeetCode Longest Substring Without Repeating Characters Python C++ 实现
鄙人根据个人理解写的比较繁琐,大佬们海涵,如果有什么意见希望各位指点一二题目(来自leetcode网站):利用python3 或者 C++来实现题目含义基本为:从给定的一整个字符串中找出一个不包含重复字符的最长且连续的字符串,的“长度”。Given a string, find the length of the longest substring without repeatin...原创 2018-11-01 15:30:24 · 145 阅读 · 0 评论 -
LeetCode 2Sum C++
class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> out(2); for(int i=0;i<nums.size();i++){ for(int j=i+1...原创 2018-10-31 20:41:55 · 264 阅读 · 0 评论 -
LeetCode 2Sum python
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for x in nums: first_i...原创 2018-10-31 20:40:36 · 238 阅读 · 0 评论 -
【LeetCode】3Sum Closest 【python c++】
题目:从给定的数字中找出3个之和 最接近给的的target的那三个数之和这道题我一开始想错了,最后看了讨论区写的Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum ...原创 2018-11-12 21:34:48 · 139 阅读 · 0 评论