title: How to implement lexicographical order string converter (Longest Increasing Subsequence)?
body: <p>I was recently taking part in some kind of online test from java language.</p>
  
  <p>In one of question, I was asked to implement a function, that given a string will return a minimal number of characters that must be removed from the string to get new lexicographical ordered string.</p>
  
  <p>That mean, when we pass string "banana" to our method, it will return 3. </p>
  
  <p>From word "banana" we need to remove 1st letter ("b"), 3rd letter("n") and 6th letter ("a"), to get string "aan". </p>
  
  <p>There is no possibility to remove fewer letters.</p>
  
  <p>I was trying to figure the solution out for quite a long time but without any effect. </p>
  
  <p>One thing that could work would be checking every possible sub-string from our original string, checking if it is ordered and comparing the number of removed digits but it would be terrible for longer strings.</p>
  
  <p>Any ideas for algorithm?</p>