码迷,mamicode.com
首页 >  
搜索关键字:palindrome    ( 1561个结果
[Leetcode] Palindrome Linked List
一、因为要判断左右链表的断电的对称,可以先将节点取出,放到vector当中,然后使用随机访问的方式对其进行对称性判断空间复杂度为 O(n),时间复杂度为O(n)二、可否将空间复杂度降下来,可以采用两个指针,将链表分为两部分。dummy->head从dummy开始一个指针每次前进一步,另一个指针每次前...
分类:其他好文   时间:2015-08-02 13:06:59    阅读次数:158
Gym 100570E : Palindrome Query
线段树(单点更新,区间查询),维护区间字符串哈希值
分类:其他好文   时间:2015-08-02 13:04:40    阅读次数:78
[LeetCode][Java] 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 [ ...
分类:编程语言   时间:2015-07-31 23:35:54    阅读次数:196
(easy)LeetCode 234.Palindrome Linked List
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?思想:转置后半段链表节点,然后比较前半段和后半段节点的值是否相等。代码如...
分类:其他好文   时间:2015-07-31 19:54:03    阅读次数:109
LeetCode234——Palindrome Linked List,O(n) time and O(1) space
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? 实现; bool isPalindrome(ListNode* head) {         if (head == NULL || he...
分类:其他好文   时间:2015-07-31 13:11:34    阅读次数:115
不使用额外空间,检查整数是否是回文结构
Question: Given an Integer, you need to determine if it is a palindrome or not. You should not use any extra space in the process.Input: 121Output: Pa...
分类:其他好文   时间:2015-07-31 12:31:03    阅读次数:132
234. Palindrome Linked List
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?先找到链表中点,将第二部分反转,然后比较两部分链表的值。/** * De...
分类:其他好文   时间:2015-07-31 06:36:32    阅读次数:91
leetcode:Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:其他好文   时间:2015-07-31 01:08:14    阅读次数:197
算法题——回文链表
import java.util.*; /* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } }*/ public class Palindrome { public boolean isPalindr...
分类:编程语言   时间:2015-07-30 11:28:25    阅读次数:141
POJ 3280 Cheapest Palindrome(区间DP)
经典的区间DP,对于每个字符,在原字符串加上这个字符的代价是一个值,移除又是一个值,求把原字符串变成回文串的最小代价。经典的区间DP,状态转移方程见代码。在输入进行了一个处理,我们把对一个字符的增与删的操作的代价压缩成为一个数,代表对该字符进行增或删代价,把另一个相对较大的代价则忽略掉。因为在一遍插入一个字符与在另一边删除一个同样的字符对形成的贡献效果一样(可以仔细思考一下)。...
分类:其他好文   时间:2015-07-29 19:27:11    阅读次数:162
1561条   上一页 1 ... 89 90 91 92 93 ... 157 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!