Posts

Showing posts from July, 2022

HackerRank - Prepare|Algorithms|Strings|Separate the Numbers

Image
  A numeric string,   , is   beautiful   if it can be split into a sequence of two or more positive integers,   , satisfying the following conditions:  for any   (i.e., each element in the sequence is   more than the previous element). No   contains a leading zero.  For example, we can split   into the sequence  , but it is  not  beautiful because   and   have leading zeroes. The contents of the sequence cannot be rearranged.  For example, we can split   into the sequence  , but it is not beautiful because it breaks our first constraint (i.e.,  ). The diagram below depicts some beautiful strings: Perform   queries where each query consists of some integer string  . For each query, print whether or not the string is beautiful on a new line. If it is beautiful, print  YES x , where   is the first number of the increasing sequence. If there are multiple such values of  , choose the smallest. Otherwise, print  NO . Function Description Complete the  separateNumbers  function in the editor