ACC Coding4
ACC Coding4
Question-1
Write a function to validate if the provided two strings are anagrams or not. If the two
strings are anagrams, then return ‘yes’. Otherwise, return ‘no’.
Input:
Input 1: 1st string
Input 2: 2nd string
Output:
(If they are anagrams, the function will return ‘yes’. Otherwise, it will return ‘no’.)
Example
Input 1: Listen
Input 2: Silent
Output:
Yes
Explanation
Listen and Silent are anagrams (an anagram is a word formed by rearranging the letters
of the other word).
Question-2
For writing numbers, there is a system called N-base notation. This system uses only N-based symbols. It uses symbols that are
listed as the first n symbols. Decimal and n-based notations are 0:0, 1:1, 2:2, …, 10:A, 11:B, …, 35:Z.
Perform the function: Chats DectoNBase(int n, int num)
This function only uses positive integers. Use a positive integer n and num to find out the n-base that is equal to num.
Steps
•Select a decimal number and divide it by n. Consider this as an integer division.
•Denote the remainder as n-based notation.
•Again divide the quotient by n.
•Repeat the above steps until you get a 0 remainder.
•The remainders from last to first are the n-base values.
Assumption Remainde
1 < n < = 36 num Divisor Quotient
Example
r
Input: 718 12 59 10(A)
N: 12
Num: 718 59 2 4 11(B)
Output: 4 12 0 4(4)
4BA
Explanation
Sample input:
N: 21
Num: 5678
Sample output:
CI8
Question-3
Example
Input:
23 45 82 27 66 12 78 13 71 86
Output:
86
9
Explanation
The maximum element is 86 and the index is 9.
Question-4
Example
Input:
N: “1210”
Output:
3
Explanation
The 0th position has the number 1, the 1st position has the number 2, the 2nd position has the number
1, and the 3rd position has number 0. Hence, it is an autobiographical number.
The count of autobiographical numbers in the input is 3, hence 3 is returned.
Question-6
In a given list of integers, find the number that has the highest frequency. If
there are one or more such numbers, give the smaller one as output.
Input:
3 (no. of test cases)
7 (size of the array) Input :
2 4 5 2 3 2 4 (array elements)
6 (no. of test cases)
121121 (size of the array)
(array elements)
10
1111111111
Output:
2
1
1
Question-7
Create web access management to the kth largest number. It will accept
an integer k and an array arr as its conditions and has to return the
greatest element based on the value of k. That is, if k = 0, return the
greatest element. If k = 1, return the second greatest element, and so on.
Example
Suppose the array contains values like {74, 85, 102, 99, 101, 56, 84} and the
integer k is 2. The method will return 99, the third greatest element, as
there are only two (according to the value of k) values greater than 99 (101
and 102).
Question-8
We have mentioned a list of integers that have no duplicates. Find how many
swaps it will take to sort the list in ascending order using Bubble sort.
Input:
3
5
21463
10
123 21 34 45 25 675 23 44 55 900
1
23
Output:
3
16
0
Question-9
Adam decides to do some charity work. From day 1 till day n, he will give i^2 coins
to charity. On day ‘i’ (1 < = i < = n), find the number of coins he gives to charity.
Example 1
Input:
2
Output:
5
Explanation:
There are 2 days.
Example 2
Input:
3
Output:
14
Question-10
Perform a function to reverse a string word-wise. The input here will be the string. In the output, the
last word mentioned should come as the first word and vice versa.
Example
Input:
Welcome to code
Output:
code to Welcome
Explanation
The Reversed string word wise function is applied.
Example
Input:
Code to Crack Puzzle
Output:
Puzzle Crack to Code
.
Question-11
Execute a function that accepts the integer array of length ‘size’ and finds
out the maximum number that can be formed by permutation.
Note: You will have to rearrange the numbers to make the maximum
number.
Example
Input:
34 79 58 64
Output:
98765443
Explanation
All digits of the array are 3, 4, 7, 9, 5, 8, 6, and 4. The maximum number
found after rearranging all the digits is 98765443.
THANK YOU