随笔分类 -  leetcode

上一页 1 ··· 8 9 10 11 12 13 14 15 下一页
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded 阅读全文
posted @ 2017-06-12 14:51 鸭子船长 阅读(313) 评论(0) 推荐(0)
摘要:I: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exa 阅读全文
posted @ 2017-06-09 18:29 鸭子船长 阅读(253) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-06-09 15:48 鸭子船长 阅读(195) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-06-09 15:03 鸭子船长 阅读(264) 评论(0) 推荐(0)
摘要: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 re 阅读全文
posted @ 2017-06-08 17:56 鸭子船长 阅读(243) 评论(0) 推荐(0)
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up:Can you solve it without using extra space? 快 阅读全文
posted @ 2017-06-07 23:09 鸭子船长 阅读(364) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 若在while开始时判断fast==slow,会出现误判,即第一次循环时fast 阅读全文
posted @ 2017-06-07 23:02 鸭子船长 阅读(201) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-06-07 22:53 鸭子船长 阅读(158) 评论(0) 推荐(0)
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree{1,#,2,3}, return[1,2,3]. Note: Recursive soluti 阅读全文
posted @ 2017-06-07 17:03 鸭子船长 阅读(215) 评论(0) 推荐(0)
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree{1,#,2,3}, return[3,2,1]. Note: Recursive solut 阅读全文
posted @ 2017-06-07 16:52 鸭子船长 阅读(270) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort. PS:需要考虑left为head且只有一个数时,此时left->==NULL,若right<left则应更新left。 比较p->next->val与right->val以此来避免需要记录preNode 阅读全文
posted @ 2017-06-07 16:32 鸭子船长 阅读(267) 评论(0) 推荐(0)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 链表,快慢指针找中点,归并排序。 注意判断条件fast->next!=NULL&&fast->next->next!=NULL,若为fast!=NULL&&f 阅读全文
posted @ 2017-06-07 11:29 鸭子船长 阅读(185) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 找出二维平面上处于同一条直线上的最大点数 PS: map用法。for(auto pair:slope 阅读全文
posted @ 2017-06-06 18:21 鸭子船长 阅读(172) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expre 阅读全文
posted @ 2017-06-06 18:01 鸭子船长 阅读(151) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le 阅读全文
posted @ 2017-06-06 17:37 鸭子船长 阅读(287) 评论(0) 推荐(0)
摘要:一、 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. F 阅读全文
posted @ 2017-06-06 00:20 鸭子船长 阅读(1588) 评论(0) 推荐(0)
摘要: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 c 阅读全文
posted @ 2017-01-16 18:39 鸭子船长 阅读(202) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
posted @ 2017-01-16 10:06 鸭子船长 阅读(115) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-01-12 18:21 鸭子船长 阅读(163) 评论(0) 推荐(0)
摘要: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 p 阅读全文
posted @ 2017-01-12 17:00 鸭子船长 阅读(284) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 14 15 下一页