How do I develop an algorithm?

I recently got interviewed at a company for a new grad SDE position where I was asked to develop an algorithm that will generate unique numbers for strings. I was confused on how should I do that. How should I approach this question?

  • Answer:

    SHA-512 for example, not strictly unique though. Better yet, suppose that base of the system is |Alphabet|+1, now calculate number based on string, numeric representation of a string. For example, abb and alphabet a-z, |alphabet| = 26 => base = 27. abb = 1 + 2 * 27 + 2 * 27 * 27 => here is your number.

Roman Dzhabarov at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.