![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode_cpp_python
文章平均质量分 62
limwz
这个作者很懒,什么都没留下…
展开
-
leetcode之Min Stack
问题描述如下:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.原创 2014-12-03 15:16:52 · 224 阅读 · 0 评论 -
leetcode之Reorder List
问题描述如下:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, r原创 2014-12-06 10:15:48 · 252 阅读 · 0 评论 -
leetcode之Linked List Cycle II
问题描述如下:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?问题链接cpp代码如下:class Solution原创 2014-12-06 10:21:42 · 240 阅读 · 0 评论 -
leetcode之Copy List with Random Pointer
问题描述如下:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.问题链接cpp代码如下:cla原创 2014-12-06 14:25:58 · 286 阅读 · 0 评论 -
leetcode之Word Break II
问题描述如下:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example,原创 2014-12-06 10:43:16 · 337 阅读 · 0 评论 -
leetcode之Word Break
问题描述如下:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",d原创 2014-12-06 10:49:34 · 281 阅读 · 0 评论 -
leetcode之Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2014-12-06 14:41:50 · 305 阅读 · 0 评论 -
leetcode之Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to原创 2014-12-06 15:14:16 · 261 阅读 · 0 评论 -
leetcode之Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each原创 2014-12-06 15:49:04 · 312 阅读 · 0 评论 -
leetcode之Single Number II
问题描述如下:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement i原创 2014-12-06 14:39:09 · 278 阅读 · 0 评论 -
leetcode之Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on原创 2014-12-06 14:57:46 · 302 阅读 · 0 评论 -
leetcode之LRU Cache
问题描述如下:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) o原创 2014-12-06 09:47:36 · 301 阅读 · 0 评论 -
leetcode之Linked List Cycle
问题描述如下:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?问题链接cpp代码如下:class Solution {public: bool hasCycle(ListNode *he原创 2014-12-06 10:25:10 · 266 阅读 · 0 评论 -
leetcode之Intersection of Two Linked Lists
问题描述如下:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘原创 2014-12-03 14:24:43 · 276 阅读 · 0 评论 -
leetcode之Find Minimum in Rotated Sorted Array II
问题描述如下:Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at原创 2014-12-03 15:43:09 · 250 阅读 · 0 评论 -
leetcode之Find Minimum in Rotated Sorted Array
问题描述如下:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplica原创 2014-12-03 15:48:18 · 221 阅读 · 0 评论 -
leetcode之Max Points on a Line
问题描述如下:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.问题链接cpp代码如下:class Solution {public: int maxPoints(vector &points) { i原创 2014-12-04 15:22:21 · 267 阅读 · 0 评论 -
leetcode之Reverse Words in a String
问题描述如下:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:Wha原创 2014-12-04 13:58:57 · 279 阅读 · 0 评论 -
leetcode之Evaluate Reverse Polish Notation
问题描述如下:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:原创 2014-12-04 14:14:56 · 248 阅读 · 0 评论 -
leetcode之Sort List
问题描述如下:Sort a linked list in O(n log n) time using constant space complexity.问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接 问题链接cpp代码如下:class Solution {public: ListNode原创 2014-12-05 09:33:36 · 284 阅读 · 0 评论 -
leetcode之Insertion Sort List
问题描述如下:Sort a linked list using insertion sort.问题链接cpp代码如下:class Solution {public: ListNode *insertionSortList(ListNode *head) { if(head==NULL||head->next==NULL)return head;原创 2014-12-05 09:52:14 · 219 阅读 · 0 评论 -
leetcode之Binary Tree Postorder Traversal
问题描述如下:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Re原创 2014-12-06 09:55:41 · 252 阅读 · 0 评论 -
leetcode之Binary Tree Preorder Traversal
问题描述如下:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Rec原创 2014-12-06 10:01:11 · 222 阅读 · 0 评论