lkjhgfdsa
BAN USER- 0of 0 votes
AnswersGiven a set of strings (denoting URLs), like:
- lkjhgfdsa in United States
1. abc.pqr.google.com
2. pqr.google.com
3. pqr.google.net
4. yahoo.com
5. abc.yahoo.com
etc...
find an efficient way to find out how many times a particular string appears as a substring. For e.g., given the above set of strings, "google.com" appears twice; ".com" appears four times, "pqr.google.com" appears twice, and so on.
Follow up: How would you do this, if the input was no longer a URL (So, "abc.pqr.google.com" and "pqr.abc.google.com", both are valid)?| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersGiven an array of strings, find out in how many cases is any of the anagrams of the string at location i, a substring of the string at location i+1.
- lkjhgfdsa in United States
Test Case I: ["ab", "ab", "abc", "bca"]
Answer: 3
Test Case II: ["ab","aqb"]
Answer: 0| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm
This question was asked to one of my friends, so I am not sure about the exact question details. I have the following questions:
1. How is a function passed to another function?
2. Can't we just use the sleep method?
I think this to be a system design question.
Hi ChrisK,
Thank you for your response.
Your points are pretty good; I realized that I should have asked him if "e.c" is a valid substring as well (in this context). From his example though, I feel as if he is splitting the strings on the basis of the dots.
As for the follow-up, I think we cannot leverage the existing trie structure from step 1:
root
/ \
.com .net
/ \ \
Google Yahoo Google
/ | |
pqr abc pqr
|
abc
As per my understanding, what he meant was, we would have to modify the tree if `abc` now became a parent of `pqr` (as per the follow up). This is what I could understand as per my discussion with him. That is when I thought if a hash table might be useful.
- lkjhgfdsa October 28, 2017@SomeOneOnTheInternet:
"ab" (at i=0) has two anagrams "ab" and "ba" of which, "ab" is a substring of "ab"(at i=1). Thus, `counter` is `1`. The string "ab"(at i=1) which is an anagram of itself is the substring of string "abc" (at i=2). Thus `counter` is now 2. One of the anagrams of "abc"(at i=2) is "bca" which is a substring of "bca" at (i=3). This makes the counter `3`, which is now our answer!
RepDiscover the best preschool for kids Charlotte. Visit Pal-A-Roo’se, one of the trusted early childhood & child development center in ...
RepStevenBLuis, Data Scientist at Achieve Internet
Choose the best quality vaping accessories at Ny Vape Shop. With different types of quality vaporizers, we are one of ...
Yes, it makes sense. Thank you as always, ChrisK! :)
- lkjhgfdsa December 11, 2017