Commonly Asked Algorithm Interview Questions | Set 1 - GeeksQuiz
Given a row of n coins of values v1 . . . vn, where n is even. We play a game against an opponent by alternating turns. In each turn, a player selects either the first or last coin from the row, removes it from the row permanently, and receives the value of the coin. Determine the maximum possible amount of money we can definitely win if we move first.
This is also a Dynamic Programming Question. See Optimal Strategy for a Game for more details.
You are given an array of sorted words in an arbitrary language, you need to find order (or precedence of characters) in the language. For example if the given arrays is {"baa", "abcd", "abca", "cab", "cad"}, then order of characters is 'b', 'd', 'a', 'c'. Note that words are sorted and in the given language "baa" comes before "abcd", therefore 'b' is before 'a' in output. Similarly we can find other orders.
This can be solved using two steps: First create a graph by processing given set of words, then do topological sorting of the created graph, See this for more details.
We will soon be adding more questions.
You may also like to see Commonly Asked Data Structure Interview Questions | Set 1
Read full article from Commonly Asked Algorithm Interview Questions | Set 1 - GeeksQuiz
No comments:
Post a Comment