algorithm - Add an object to an Array based on dictionary Array -
i believe algorithm question, doesn't matter language in, although think in case implemented in jquery.
so idea have 2 arrays of type object. in object there many variables, relevant 1 string. lets argument sake, have array [a, a, a, a, b, b, e, e, f] , 'dictionary' array [a, b, c, d, e, f]. whenever want add first array, want added location of object in second array. instance, if wanted add d, first array [a, a, a, a, b, b, d, e, e, f].
to add d, there not c or d search put d in after. in addition, there can repeats in example. array empty program adding 'd' to. also, if there ds in first array, d go after last d.
important: letters used clarification sake, actual code uses words not in alphabetical order, solutions using alphabetical order not work in instance.
is there better solution brute force?
Comments
Post a Comment