LeetCode(131)Palindrome Partitioning】的更多相关文章

题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"], ["a","a",&q…
题目 Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 分析 判断一个链表是否为回文. 要求时间复杂度O(n) 空间复杂度O(1) 若是可用辅助空间,则其是一个简单的题目,我们可用利用一个辅助数组存储节点元素val值,然后判断数组是否回文即可. 题目要求O(1)的空间复杂度,不能用辅助空间.我们只能从链表本身下手,…
题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could…
Leetcode(4)寻找两个有序数组的中位数 [题目表述]: 给定一个字符串 s,找到 s 中 最长 的回文子串.你可以假设 s 的最大长度为 1000.' 第一种方法:未完成:利用回文子串的特点 一开始我的思路如下:回文子串的特点是首尾字母相同,所以我对每一个字母都找到位于它后面的相同字母,利用切片判断这一段是否为回文子串(str[i:j]==str[i:j][::-1]).时间复杂度很高,主要是因为str.find操作非常耗时. class Solution(object): def lo…
用zabbix的同学都知道,一台服务器监视几百几千台服务器,一个服务器几十个item,长年下来数据量是很惊人的. 而zabbix自带的housekeeping功能,默认状态下的删除速度完全跟不上数据增长的速度. 而一旦把删除量加大,CPU磁盘又开始报警了,严重的情况下,监视都会中断. 为了防止这种问题,我们采用了mariaDB(mysql)的partitioning功能. partitioning功能的开启最好是在服务器搭建的初期就设计并配置好. 一旦服务器运行了一段时间,partitionin…
新概念英语(1-31)Where's Sally? Is the cat climbing the tree ? A:Where is Sally, Jack ? B:She is in the garden, Jean. A:What's she doing? B:She's sitting under the tree. A:Is Tim in the garden too ? B:Yes he is. He is climbing the tree. A:I beg your pardon…
题目 Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? 分析 同LeetCode(274)H-Index第二个版本,给定引用数量序列为递增的:这就省略了我们的第一个排序步骤: O(n)的时间复杂度,遍历一次即可. AC代码 class Solution { public: int hIndex(vector<int>…
题目 Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is at most k. 分析 题目描述:给定一个整数序列,查找是否存在两个下标分别为i和j的元…
题目 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 some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh…
题目 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times).…