Skip to main content

All Questions

2votes
1answer
158views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...
Sam Jing Wen's user avatar
2votes
3answers
1kviews

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
2votes
0answers
319views

KMP algorithm in scala

I implemented KMP pattern matching algorithm in Scala. My code works but it looks more imperative and a scala translation of C/C++ implementation. I am not able to figure out how to manage multiple ...
vikrant's user avatar
0votes
1answer
531views

Print words in decreasing order of frequency in Scala

Given a string print its words in decreasing order of frequency. Example: i/p - "aa bbb ccc aa ddd aa ccc" o/p - aa,ccc,ddd,bbb Scala: ...
vikrant's user avatar
3votes
1answer
251views

Map Character to Characters Most Frequently Found With it (in list of strings)

For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let'...
dfrey's user avatar
3votes
4answers
3kviews

Find longest Palindrome substring

I am preparing for technical interview and I found this question on geeksforgeeks, but I did not understand their solution. So, I have written my own solution. I want to optimize this code. ...
coder's user avatar
  • 2,461
10votes
2answers
287views

Python implementation of find_all_indexes

I got asked this question before in an interview. For example, find_all_indexes('ababc', 'abc') returns 2. This Python function ...
NinjaG's user avatar
  • 2,539
5votes
2answers
4kviews

Find the smallest substring that contains some given subset of characters

Problem statement: Given a string as a "source" string, find the smallest substring of source such that it contains all characters in "search" string (which contains distinct characters). For ...
Jianmin Chen's user avatar
4votes
2answers
722views

Checking whether any anagram of a string appears within another string

I have the following code that takes a string t and checks to see if any anagram of t is a substring of ...
Calvin Ellington's user avatar
0votes
3answers
2kviews

Detecting if two given strings are isomorphic using Java data structures

So I have written the following code and it works for various same length isomorphic strings I have tried. However I am not sure what are some time complexity improvements and coding tweaks that could ...
Mona Jalal's user avatar
4votes
1answer
443views

Finding number of times each string in an Array of strings occurs in a large stream of characters (i.e large string)

Interview problem: Given a stream of characters (e.g. acacabcatghhellomvnsdb) and a list of words (e.g. ["aca","cat","hello","world"] ) find and display count of each and every word once the stream ...
Smart Home's user avatar
3votes
1answer
844views

Acquiring indices for anagrams of an input string

I am working on an interview question from Amazon Software: Design an algorithm to take a list of strings as well as a single input string, and return the indices of the list which are anagrams of ...
committedandroider's user avatar
6votes
5answers
7kviews

Given a String, return a boolean if it is a number

Yesterday in an online interview, the interviewer asked me this question: If I give you a string, you have to return if a string is number or not. You are not allowed to use any parse function ...
daydreamer's user avatar
4votes
1answer
3kviews

Finding the longest unique sub-string in a string

I recently interviewed with a company for software engineering position. I was asked the question of finding the longest unique sub-string in a string. My algorithms was as follows: Start from the ...
aandis's user avatar
3votes
7answers
780views

Delete the characters of one string from another string

I've got an interview coming up for which the following is a prospective question: Given 2 strings, for instance: John Lennon Paul ON delete every character from string 1 which ...
Ritesh Bhakre's user avatar

153050per page
close