Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
7 votes
1 answer
346 views

Create tweet threads from String in Java

I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The ...
isanma's user avatar
  • 73
10 votes
4 answers
3k views

First non-repeating Character, with a single loop in Python

I recently tried to solve the first non-repeating character problem. Please tell me if my solution is valid. I'm aiming for O(n) with a single loop. My thinking is, it would be easy to tell you what ...
zing's user avatar
  • 203
7 votes
2 answers
827 views

Number of occurrences of strings in array

This is a Hackerrank problem (https://www.hackerrank.com/challenges/sparse-arrays/problem). We're given an array of strings and an array of queries, and have to return an array of the number of ...
jeremy radcliff's user avatar
10 votes
6 answers
1k views

Primitive String trimmer in C

I just picked up C and am following through The C programming language. I've previously got experience with a lot of 'higher'-level languages, so when I saw this exercise in the book: Write a ...
geostocker's user avatar
5 votes
1 answer
744 views

Sequence Alignment of two Strings

I have some code which aligns the sequence of two strings, I am doing numbers just for my implementation. I was wondering whether there are any performance enhancements I could make as the code ...
user3667111's user avatar
7 votes
1 answer
2k views

Cipher text using a 2D array

I have a simple program which ciphers text using a 2D array. You specify what letters to replace with what and it does it. I understand the code is very repetitive and that I should probably use ...
Theodore Falcone's user avatar
1 vote
1 answer
486 views

Removing a specific character and its neighbors from a string

Assume we have an string that contains the character 'c'. This character can be located anywhere within the string. The exercise ...
CodesInValley's user avatar
5 votes
1 answer
655 views

Anagram finder in F#

I've been learning F# for a month or so and I'm wondering how good my "functional" aspect of coding is. When I first started, I did this using an iterative approach with a lot of <- and mutables ...
Luke Xu's user avatar
  • 195
4 votes
2 answers
213 views

Palin Pairs (Pallindrome Counting) Code

In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time ...
Ravi's user avatar
  • 171
2 votes
2 answers
2k views

Given suffix array and a pattern, search if given pattern exists

Given a suffix array for a word, check if a pattern (consecutive chars) exists. Example: A suffix array constructed for "ameya" should return true for "ame" but false for "foo" or false for "...
JavaDeveloper's user avatar
2 votes
6 answers
8k views

Remove specific consecutive element in array

I'm trying to reduce consecutive elements of array to one, but not for all values like: {3,0,0,0,3,3,3,0,0,0} => {3,0,3,0} but for specific one, in my example ...
robosoul's user avatar
  • 217