title-img


Array Reversal

Given an array, of size n, reverse it. Example: If array, arr=[1.2.3.4,5] after reversing it, the array should be, arr=[5,4,3,2,1] Input Format: The first line contains an integer, n, denoting the size of the array. The next line contains n space-separated integers denoting the elements of the array. Constraints: 1<=n<=1000 1<=arr[i]<=1000, where is the element of the array. Output Format: The output is handled by the code given in the editor, which would print the ar

View Solution →

Printing Tokens

Given a sentence, s, print each word of the sentence in a new line. Input Format: The first and only line contains a sentence, s. Constraints: 1<=len(s)<=1000 Output Format: Print each word of the sentence in a new line.

View Solution →

Digit Frequency

Given a string, s, consisting of alphabets and digits, find the frequency of each digit in the given string. Input Format: The first line contains a string, num which is the given number. Constraints: 1<=len(num)<=1000 All the elements of num are made of english alphabets and digits. Output Format: Print ten space-separated integers in a single line denoting the frequency of each digit from 0 to 9.

View Solution →

Hash Tables: Ransom Note

Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use only whole words available in the magazine. He cannot use substrings or concatenation to create the words he needs. Given the words in the magazine and the words in the ranso

View Solution →

Two Strings

Given two strings, determine if they share a common substring . A substring may be as small as one character. For example, the words "a", "and", "art" share the common substring a. The words "be" and "cat" do not share a substring. Function Description Complete the function twoStrings in the editor below. It should return a string, either YES or NO based on whether the strings share a common substring. twoStrings has the following parameter(s): s1, s2: two strings to analyze .

View Solution →