title: How to Determine the K^th character in the concatenated string
body: <p>Given a list that contains <strong>N</strong> strings of lowercase English alphabets. Any number of contiguous strings can be found together to form a new string. The grouping function accepts two integers <strong>X</strong> and <strong>Y</strong> and concatenates all strings between indices <strong>X</strong> and <strong>Y</strong> (inclusive) and returns a modified string in which the alphabets of the concatenated string are sorted.</p>
  
  <p>You are asked <strong>Q</strong> questions each containing two integers <strong>L</strong> and <strong>R</strong>. Determine the $K^{th}$. character in the concatenated string if we pass <strong>L</strong> and <strong>R</strong> to the grouping function.</p>
  
  <h3>Input Format</h3>
  
  <ul>
  <li>First Line: <strong>N</strong>(number of strings in the list)</li>
  <li>Next <strong>N</strong> lines: String $S_i$</li>
  <li>Next line <strong>Q</strong>(number of questions)</li>
  <li>Next <strong>Q</strong> lines : Three space-separated integers <strong>L</strong>, <strong>R</strong> and <strong>K</strong></li>
  </ul>
  
  <h3>Output Format</h3>
  
  <ul>
  <li>For each question, print the $K^{th}$ character of the concatenated string in a new line.</li>
  </ul>
  
  <h3>Sample Test Cases</h3>
  
  <pre><code>Sample Input                 Sample Output
  
  5                                 c
  aaaaa                             d
  bbbbb                             e
  ccccc
  ddddd
  eeeee
  3
  3 3 3 
  1 5 16
  3 5 15
  </code></pre>
  
  <h3>Explanation</h3>
  
  <ul>
  <li><strong>Q1</strong> Grouped String - <em>ccccc</em>. 3rd character is <strong>c</strong></li>
  <li><strong>Q2</strong> Grouped String - <em>aaaaabbbbbcccccdddddeeeee</em>. 16th character is <strong>d</strong></li>
  <li><strong>Q3</strong> Grouped String - <em>cccccdddddeeeee</em>. 15th character is <strong>e</strong></li>
  </ul>
  
  <p><strong>Note:</strong> It is always guaranteed that the $K^{th}$ position is valid</p>
  
  <p><strong>CONTEXT:</strong></p>
  
  <p>This question came up in a Hiring Challenge I did back in October. I just remembered this question and thought I'd have a go but I am still struggling with it.</p>
  
  <p>There are no worked solutions online so I'm reaching out to this website as a final resort. Any help would be greatly appreciated. Thank you!</p>