Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
72 views

String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)

This is my code to solve the 5th Adventjs challenge. In that link you can read the instructions. How can I improve it? It's a bit messy... and I'm repeating some part of the code. All must be in just ...
Sofia Chardin's user avatar
4 votes
3 answers
841 views

Codewars: Multiplying Polynomials

I'm trying to solve the following Kata from Codewars in Python. My code produces the desired result for all the tests, yet it is not optimal, so it takes too much time to accomplish the big tests. <...
GuntherOnFire's user avatar
2 votes
1 answer
176 views

An evolutionary algorithm written in Java to crack an XOR cipher

Alright. So TryHackme is a website that tries to teach hacking with hands on labs. They have a room called JVM Reverse Engineering where the user gets to reverse engineer Java apps, and in particular ...
Aleksey's user avatar
  • 183
2 votes
1 answer
185 views

follow-up - Checking Nested Bracket Levels in Strings Programming Challenge

A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
T145's user avatar
  • 3,099
1 vote
2 answers
155 views

Find longest palindrome in a string (LeetCode problem 5)

The code below is my solution to the following problem (problem #5 on LeetCode): Given a string s, return the longest palindromic substring in s. I wonder whether my use of iterators is an overkill. ...
AlwaysLearning's user avatar
2 votes
3 answers
1k views

Find the 'n' most frequent words in a text, aka word frequency

I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
NPN328's user avatar
  • 761
2 votes
3 answers
202 views

Phrase to acronym in C from exercism.io

I am learning C and doing challenges like those found on exercism.io and the various data structure & algorithm sites. I have a sense that while this works and it makes sense to me that it can be ...
jgnovak-dev's user avatar
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
2 votes
2 answers
984 views

InterviewBit Problem: Stringoholics

I am trying to solve this InterviewBit problem. Problem Statement: You are given an array A consisting of strings made up of the letters ‘a’ and ‘b’ only. Each string goes through a number of ...
Setu Kumar Basak's user avatar
6 votes
1 answer
644 views

LeetCode 1638: Count Substrings That Differ by One Character

I'm posting a solution for LeetCode's "Count Substrings That Differ by One Character". If you'd like to review, please do. Thank you! Problem Given two strings s and t, find the number of ...
Emma's user avatar
  • 3,517
9 votes
1 answer
2k views

LeetCode on Longest Palindromic Substring in Python

This is a programming question from LeetCode: Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is ...
user avatar
5 votes
4 answers
2k views

C#: Repeated String

From HackerRank "Repeated String" challenge: Lilah has a string, \$s\$, of lowercase English letters that she repeated infinitely many times. Given an integer, \$n\$, find and print the ...
wayne.blackmon's user avatar
4 votes
1 answer
171 views

LeetCode: Find And Replace in String C#

It took me a while to solve this question and there are corner cases i missed hence the 4 unit tests. please review for performance. and if you can treat this as a review for a 45 mins programming ...
Gilad's user avatar
  • 5,283
2 votes
2 answers
354 views

Exercism: determine if a word or phrase is an isogram

The task: Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed ...
Konstantin Kostanzhoglo's user avatar
6 votes
3 answers
982 views

C: function to read a token from stdin

I recently started doing some competitive programming in C and one of my first requirements was a high-speed token reader (analogous to the java Scanner class' <...
Aniruddha Deb's user avatar
5 votes
3 answers
402 views

Add two digit strings and return the result as string

I haven't done C in a while. This looks like a simple problem to start. Leetcode problem 415 Given two non-negative integers num1 and ...
wispymisty's user avatar
0 votes
2 answers
1k views

Sherlock and Anagrams in Javascript

I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
leonheess's user avatar
  • 161
4 votes
1 answer
223 views

Determining whether a string is transformable into another by repetitively increasing its prefixes alphabetically

Here's Alice and Strings, a programming challenge on hackerearth: Two strings \$A\$ and \$B\$ comprising of lower case English letters are compatible if they are equal or can be made equal by ...
PasanW's user avatar
  • 185
3 votes
1 answer
2k views

Find and return the earliest occurring word from a string which contains the most repeating letters

I'd like feedback on my solution to the outlined programming challenge (medium level). I've tried it fast in any way I know how to, but, what might be a more efficient and/or pythonic solution? [...
Dave's user avatar
  • 753
3 votes
1 answer
3k views

Run length encoding of an input string (Coderbyte 'Run Length' challenge)

I'd like feedback on my solution to the outlined (medium level) programming challenge. What might be a more efficient or Pythonic solution? The challenge as outlined by Coderbyte: [Run Length] (...
Dave's user avatar
  • 753
3 votes
1 answer
2k views

Codewars: Sum Strings

Sum Strings Codewars kata. It's supposed to be able to handle big integers.   Question Given the string representations of two integers, return the string representation of the sum of those integers. ...
Tobi Alafin's user avatar
  • 1,796
2 votes
1 answer
805 views

LeetCode: Greatest Common Divisor of Strings C#

https://leetcode.com/problems/greatest-common-divisor-of-strings/ For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or more times) ...
Gilad's user avatar
  • 5,283
2 votes
0 answers
284 views

Split a string into valid words

I am trying to solve this LeetCode question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word ...
nz_21's user avatar
  • 1,041
5 votes
4 answers
1k views

Confirm the ending of a string

Challenge: Check if a string (first argument, str) ends with the given target string (second argument, target). This ...
DreamVision2017's user avatar
5 votes
1 answer
3k views

Convert a hex string to base64

I wrote a program that converts a hex-encoded string to base64. It's my solution to the first of the Cryptopals challenges. My main concerns are: Portability. I don't want to rely on implementation-...
flornquake's user avatar
5 votes
2 answers
305 views

Leetcode longest substring with no duplicates

...
neet's user avatar
  • 91
6 votes
3 answers
2k views

LeetCode: Group Anagrams C#

LeetCode: Group Anagrams C# Given an array of strings, group anagrams together. ...
Gilad's user avatar
  • 5,283
2 votes
0 answers
760 views

Rosalind - Finding a Shared Motif

Here is my attempt to implement the Ukkonen algorithm for the Finding a Shared Motif problem on rosalind.info. The code works, it produces a correct answer. It does so in 11 seconds. I am hoping to ...
Andrew Au's user avatar
  • 525
2 votes
1 answer
1k views

CodingBat: without_end

Link To Question Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2. without_end('Hello') → 'ell' ...
Linny's user avatar
  • 10.3k
4 votes
2 answers
761 views

Letter case permutation

The question can be found here https://leetcode.com/problems/letter-case-permutation Given a string S, we can transform every letter individually to be lowercase or uppercase to create another ...
user avatar
6 votes
2 answers
231 views

String manipulation with std::adjacent_find

For the given strings (not containing numbers), print their shortened versions, where each adjacent sequence of the same characters longer than 2, change to an expression consisting of a sign and ...
Dessus's user avatar
  • 300
1 vote
1 answer
5k views

String Rotation

I have solved a previous year question of 2018 codevita (link) in Python. Problem Description: Rotate a given String in the specified direction by specified magnitude. After each rotation make a ...
itsvinayak's user avatar
1 vote
3 answers
350 views

LeetCode:implement strstr C#

https://leetcode.com/problems/implement-strstr/ I implemented Rabin-Karp algorithm https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm please review for performance, also if you were in an ...
Gilad's user avatar
  • 5,283
3 votes
1 answer
1k views

Shortest way to form a string out of a subsequence of a string

The task is taken from LeetCode (subscription required) - From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings ...
thadeuszlay's user avatar
  • 3,993
3 votes
1 answer
109 views

CareerCup (Bloomberg): Check if string is valid based on brackets

The goal of this problem is to determine if a string with brackets is valid. Below is a summary of the question from careercup. Check if string s is valid based on brackets ...
RockLeeroy's user avatar
2 votes
1 answer
176 views

Coding Challenge: Return The Smaller String

A coding challenge in which we are to write a function that compares two strings and returns the one that is smaller. The comparison is both lexicographical and numerical, depending on the content of ...
MadHatter's user avatar
  • 837
3 votes
1 answer
3k views

Zig-zag function - coded solution

Here is my coded solution to the LeetCode zig-zag problem - The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this (you ...
MrJoe's user avatar
  • 2,053
5 votes
0 answers
364 views

Palindrome insertion challenge

Here is my solution to the following Daily Coding Problem challenge Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible anywhere in the ...
MrJoe's user avatar
  • 2,053
6 votes
3 answers
361 views

Leetcode - First Unique Character in a String

Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1. Examples: ...
Mosbius8's user avatar
  • 769
2 votes
1 answer
1k views

(Codewars): Find the Unknown Digit

Kata: https://www.codewars.com/kata/find-the-unknown-digit/train/python To give credit where credit is due: This problem was taken from the ACMICPC-Northwest Regional Programming Contest. Thank ...
Tobi Alafin's user avatar
  • 1,796
3 votes
2 answers
589 views

Find the longest sub string of a word after concatenation of given words array

An Array of N words is given. Each word consists of small letters ('a'-'z'). Our goal is to concatenate the words in such a way as to obtain a single word with longest possible substring composed of ...
Ora2gaurav's user avatar
8 votes
4 answers
4k views

Reversing a string - two approaches

Test Case: Input- "I'm hungry!" Output- "!yrgnuh m'I" Approach 1: In this approach, I used a empty string and bind it with the input string reversely. ...
AKdeBerg's user avatar
  • 195
2 votes
1 answer
219 views

String reversing x times

Inspired by CodeWars We have a string s Let's say you start with this: "String" The first thing you do is reverse it: "gnirtS" Then you will take ...
JSextonn's user avatar
  • 686
2 votes
1 answer
480 views

LeetCode #28 - Boyer Moore string matching algorithm

The following code implements the Boyer Moore string matching algorithm. The algorithm is used to find a sub-string (called the pattern) in a string (called the text) and return the index of the ...
Andrew Au's user avatar
  • 525
2 votes
1 answer
123 views

Program finds the first almost matching string in a list - Advent Of Code 2018 Day 2 Part 2

Advent of Code 2018, day 2, part 2: The [two IDs you are looking for] differ by exactly one character at the same position in both strings. For example, given the following IDs: ...
Simon Brahan's user avatar
5 votes
1 answer
4k views

Repeated Strings Hacker Rank challenge

I'm doing a hacker rank challenge with this one called "Repeated String". I attempted this challenge in my weaker language java. The goal is to print out the occurrences of the letter a. First you're ...
Laurent's user avatar
  • 89
4 votes
1 answer
515 views

Find the first non-recurring character in string

I wrote a solution to first-unique-character-in-a-string: Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1. If there is better way ...
A.Lee's user avatar
  • 341
0 votes
1 answer
1k views

CodingBat warm up: conditionally prepending "not" to a string

I solved this CodingBat problem: Given a string, return a new string where "not " has been added to the front. However, if the string already begins with "not", return the string unchanged. Note: ...
aclark's user avatar
  • 13
7 votes
3 answers
1k views

Count number of gemstones in a set of minerals

This is the "Gemstones" problem on Hackerrank. John has collected various rocks. Each rock has various minerals embeded in it. Each type of mineral is designated by a lowercase letter in the range ...
db18's user avatar
  • 387
12 votes
2 answers
4k views

Make a beautiful binary string

This is the "Beautiful Binary String" problem at HackerRank: Alice has a binary string. She thinks a binary string is beautiful if and only if it doesn't contain the substring 010. In one ...
db18's user avatar
  • 387

1
2 3 4 5