Skip to main content

All Questions

1 vote
1 answer
215 views

Finding longest palindromic substring in a string (gives TLE on leetcode)

I'm solving the Longest Palindromic Substring problem on LeetCode. And here's my final submission: ...
Joe D's user avatar
  • 113
2 votes
2 answers
10k views

Count palindrome substrings

Given a string S, count and return the number of substrings of S that are palindromes. Single length substrings are also palindromes. We just have to count the substring that are palindrome. ...
sahil mehta's user avatar
5 votes
2 answers
5k views

HackerRank Similar String

Problem Statement: https://www.hackerrank.com/challenges/similar-strings I got the logic correct. However it times out for testcase 8 onwards I would like some suggestions on optimizing this code <...
user3833308's user avatar
5 votes
3 answers
153 views

For each pair of strings, eliminate the characters they have in common

In the below code there are 3 inputs. First line of input is the number of testcases for which the program will run where (1<=testcases<=10) and i is an ...
Dev's user avatar
  • 51
3 votes
1 answer
724 views

UVa 11340 Newspaper challenge (sum of letter values in an article)

I am solving the UVA 11340 problem: Problem Description News agency pays money for articles according to some rules. Each character has its own value (some characters may have value equals to zero). ...
Md Johirul Islam's user avatar
6 votes
2 answers
10k views

Finding maximum length of continuous string which has same characters

I'm solving this problem from codeforces. I've a solution which has complexity of O(n²). But the time limit exceeds on some of the test cases. The problem statement is: High school student Vasya got ...
Kaushal28's user avatar
  • 455
3 votes
2 answers
4k views

Finding the index of the character whose removal will make a palindrome

Before I get into describing by problem I'd like to point out I found this question under c++ tag. But the solution of that question is already implemented in my ...
Kaushal28's user avatar
  • 455
13 votes
3 answers
6k views

Comparing two strings to see if string 2 is inside string 1

Here is what I have to do: Write a function scramble(str1,str2) that returns true if a portion of ...
Archeofuturist's user avatar
3 votes
1 answer
464 views

Finding the largest not-necessarily contiguous alternating binary string after inverting any sub-string from a given string

I'm having problems solving this problem within the time limit. Alternative Thinking http://codeforces.com/contest/603/problem/A Kevin has just recevied his disappointing results on the USA ...
RE60K's user avatar
  • 1,466
6 votes
5 answers
14k views

Length of the longest sequence of repeating characters

I have been going through some CodingBat exercises and I came across this problem. "Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are ...
user59810's user avatar
4 votes
2 answers
6k views

"Rotating the string" optimization

Below is the code for the problem at Codechef. I have made use of the String method .equals in my solution which is working fine ...
arunkrishnamurthy01's user avatar
3 votes
1 answer
3k views

Output strings from a set in lexicographical order

Puzzle Description: You are given 'n' strings w1, w2, ......, wn. Let Si denote the set of strings formed by considering all unique substrings of the string wi. A substring is defined as a ...
cypronmaya's user avatar