Pergunta de entrevista da empresa Apple

Create a new string from not repeated letters from the 'something else' string Result: omithingl

Respostas da entrevista

Sigiloso

13 de jan. de 2020

def find_string(s): result = "" for i in s: if s.count(i) == 1 and i != " ": result = result + i return result print(find_string("something else"))

1

Sigiloso

17 de jan. de 2022

def removedups(s): dct = {} result = [] s = s.replace(' ', '') for i in s: if i not in dct: dct[i] = 1 else: dct[i] = dct[i] + 1 for k, v in dct.items(): if v == 1: result.append(k) return ''.join(result) print(removedups('something else'))

Sigiloso

27 de ago. de 2019

enter = "Something else" n = enter.lower().replace(" ","") x = "" for y in n: count = 0 for l in n: if l == y: count += 1 if count == 1: x += y print(x)

Sigiloso

5 de nov. de 2019

function find_repeat(string){ var array = string.split(''); var remove_array = []; for(var i = 0; i < array.length; i++) { for(var j = 0; j < array.length; j++){ console.log(array[i], array[j], i , j); if(array[i] == array[j] && (i != j)){ remove_array.push(array[i]); console.log(remove_array); } } } array = array.filter(function(el){ return remove_array.indexOf(el) < 0; //Creates an array of unmuted blocks }); console.log(array); return array; } find_repeat('something else');

Sigiloso

5 de nov. de 2019

function find_repeat(string){ var array = string.split(''); var remove_array = []; for(var i = 0; i < array.length; i++) { for(var j = 0; j < array.length; j++){ if(array[i] == array[j] && (i != j)){ remove_array.push(array[i]); } } } array = array.filter(function(el){ return remove_array.indexOf(el) < 0; }); return array; } find_repeat('something else');

Sigiloso

18 de dez. de 2018

s = 'something else' ''.join(set(s.replace(' ', '')))