Posts

Showing posts from August, 2022

SPECIAL STRING ARRAY

  Consider a non-empty string array inarr and a string instr. Identify and print outarr, based on the below logic: • For the string instr, generate a list of special strings specialstringlist. o List of special strings A special string for a string stris generated by right shiftingthe characters by one position. Last character will be shifted as the first character The newly generated special string is used as str for generating the next special string in the list Repeat the generation until the original string stris reached. o List of special strings would contain the string str. • Starting from the leftmost element, for each element in inarr. o Add the element of inarr to outarr if it is a subsequence in specialstringlist § Subsequence: A subsequence of a string str in the possible set of characters formed from string starting from left to right • If none of the elements from inarr is a subsequence of specialstringlist print -1 Note:  Perform case-insensitive comparison Input Format

Hackerrank - Quicksort 2 - Sorting

Image
     Problem Submissions Leaderboard Discussions In the previous challenge, you wrote a partition method to split an array into two sub-arrays, one containing smaller elements and one containing larger elements than a given number. This means you 'sorted' half the array with respect to the other half. Can you repeatedly use partition to sort an entire array? Guideline In Insertion Sort, you simply went through each element in order and inserted it into a sorted sub-array. In this challenge, you cannot focus on one element at a time, but instead must deal with whole sub-arrays, with a strategy known as "divide and conquer". When partition is called on an array, two parts of the array get 'sorted' with respect to each other. If partition is then called on each sub-array, the array will now be split into four parts. This process can be repeated until the sub-arrays are small. Notice that when partition is called on just one of the numbers, the

Code Goda 2022 - Special Numbers

Problem Statement - 1 Mr. Agoji given a shuffled string made by randomly shuffling a special string.  A string will be called special only if it is formed by joining some special words any number of times. Special words are mapping of numbers (0 <= number < 10) to their words, for example, mapping of '0' to 'zero', mapping of  '1' to 'one', and so on.  Mr. Agoji is asked to convert the shuffled string into smallest special number. A special number is a number formed using numbers (0 <= number < 10) without any leading zeroes.  Mr. Agoji being not so good with numbers and strings ask for your help. Input Format  The first line of the input T contains the number of test cases,  1 <= T <= 100 For each test case.  There will be a, s shuffled string, on a separate line   1 <= s.length <= 100000  Output Format  For each test case, on the new line print the special number and if all the numbers are zero print zero. Sample Input  ewtooetz

Hackerrank - Prepare | Data Structures | Linked Lists | Get Node Value

  This challenge is part of a tutorial track by   MyCodeSchool Given a pointer to the head of a linked list and a specific position, determine the data value at that position. Count backwards from the tail node. The tail is at postion 0, its parent is at 1 and so on. Example  refers to  Each of the data values matches its distance from the tail. The value   is at the desired position. Function Description Complete the  getNode  function in the editor below. getNode  has the following parameters: SinglyLinkedListNode pointer head:  refers to the head of the list int positionFromTail:  the item to retrieve Returns int:  the value at the desired position Input Format The first line contains an integer  , the number of test cases. Each test case has the following format: The first line contains an integer  , the number of elements in the linked list. The next   lines contains an integer, the data value for an element of the linked list. The last line contains an integer  , the position fro