Bloomberg LP Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

"you have to print the could", do you meant count ?

- tesla August 07, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// ZoomBA. enjoy.
a = [ "abbba", "ab", "ba", "abcd", "abdc", "adbc", "aabddc" ] 
m = mset( a ) :: {  str(sset($.o.value),'') }
println( str(m.entrySet(),'\\n') -> { str( '%s:%s', $.key, size($.value) )} )

- NoOne May 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def distictPatterns(mylist):
    mydict = dict()
    for item in mylist:
        unique_set_of_chars = "".join(set(item))
        if mydict.has_key(unique_set_of_chars):
            mydict[unique_set_of_chars] += 1
        else:
            mydict[unique_set_of_chars] = 1
    for key,val in mydict.items():
        print key + ":"+ str(val)

- ankitpatel2100 May 19, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class AnagramsList {

public static void main(String[] args) {
String[] anagrams = new String[]{"aabbcc","ab","bbaa","aabccd","abcdd"};
String[] anagrams2 = new String[anagrams.length];
List<String> strings = new ArrayList<String>();
Map<String, Integer> map = new HashMap<String, Integer>();
int count = 1;
for(int i=0; i<anagrams.length; i++){
// String distStr = distinctCHarStr(anagrams[i]);
// strings.add(distinctCHarStr(anagrams[i]));
anagrams2[i] = distinctCHarStr(anagrams[i]);
}
for(int j=0; j<anagrams2.length; j++){
if(map.isEmpty() || !map.containsKey(anagrams2[j])){
map.put(anagrams2[j], 1);
}else{
if(map.containsKey(anagrams2[j])){
count = map.get(anagrams2[j]);
map.put(anagrams2[j], ++count);
}

}

}
for(String word : map.keySet()){
System.out.println(word+" : "+map.get(word));
}
}

private static String distinctCHarStr(String str){
StringBuilder sb = new StringBuilder();
Set<Character> set = new HashSet<Character>(str.length());
char[] chars1 = new char[str.length()];
chars1 = str.toCharArray();
for(char c : chars1){
set.add(c);
}
for(char c : set)
sb.append(c);

return sb.toString();
}
}

- ruppu May 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    string arr[] = {"abbba", "ab", "ba", "abcd", "adbc", "adbc", "aabddc"};
    unordered_map<string, int> str_map;
    
    for (auto val: arr) {
        sort(val.begin(), val.end());
        
        auto count = str_map[val];
        count ++;
        
        str_map[val] = count;
    }
}

- Anonymous July 30, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

unordered_map<vector<bool>, int> PatternCounts(vector<string> const &a)
{
    unordered_map<vector<bool>, int> counts;
    vector<bool> pattern;
	pattern.resize(256, false);
    for (string const &s : a) {
		fill(pattern.begin(), pattern.end(), false);
        for (char c : s) {
            pattern[c] = true;
        }
        ++counts[pattern];
    }
    return counts;
}

- Anonymous August 15, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

string create_signature(string s){
    string sig = "";
    
    for(int i = 0 ; i < s.size(); ++i){
        if(sig.find(s[i]) == string::npos)
            sig.push_back(s[i]);
    }
    
    sort(sig.begin(), sig.end());
    return sig;
}

void output_distinct_patterns(vector<string>& v){
    map<string, int> mm;
    
    for(auto s : v){
          string sig = create_signature(s);
          auto it = mm.find(sig);
          if(it == mm.end()){
              mm.emplace(sig, 1);
          }
          else{
              it->second++;
          }
    }
    
    auto iter = mm.begin();
    for(; iter != mm.end(); ++iter){
        cout << iter->first << " " << iter->second << endl;
    }
}

int main() {   
    vector<string> v = {"abbba", "ab", "ba", "abcd", "abdc", "adbc", "aabddc"};
    output_distinct_patterns(v);
    return 0;

}

- dolphinden October 02, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from collections import defaultdict

def distinctPatterns(mylist):
mydict = defaultdict(int)
for item in mylist:
unique_set_of_chars = "".join(set(item))
mydict[unique_set_of_chars] += 1
for key,val in mydict.items():
print key + ":"+ str(val)

- Nitinkumar October 18, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from collections import defaultdict

def distinctPatterns(mylist):
    mydict = defaultdict(int)
    for item in mylist:
        unique_set_of_chars = "".join(set(item))
        mydict[unique_set_of_chars] += 1
    for key,val in mydict.items():
        print key + ":"+ str(val)

- Nitinkumar October 18, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

private static void findCount(String[] strings) {
		
		Map<Set<Character>, Integer> patterns = new HashMap<>();
		for (String input : strings) {
			
			Set<Character> pattern = new TreeSet<>();
			for (char ch : input.toCharArray()) {
				pattern.add(ch);
			}
			if (patterns.containsKey(pattern)) {
				patterns.put(pattern, patterns.get(pattern)+1);
			} else {
				patterns.put(pattern, 1);
			}
		}
		for (Set<Character> exp : patterns.keySet()) {
			
			String s = exp.toString().replace("[", "").replace("]", "").replaceAll(", ", "");
			System.out.println(s + " " + patterns.get(exp));
		}
	}

- Prashant Nigam November 26, 2017 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More