Posts

problem no 66: check if two arrays are equal.

  Given two arrays   A   and   B   of equal size   N , the task is to find if given arrays are equal or not. Two arrays are said to be equal if both of them contain same set of elements, arrangements (or permutation) of elements may be different though. Note :  If there are repetitions, then counts of repeated elements must also be same for two array to be equal. Example 1: Input: N = 5 A[] = {1,2,5,4,0} B[] = {2,4,5,0,1} Output: 1 Explanation: Both the array can be rearranged to {0,1,2,4,5} Example 2: Input: N = 3 A[] = {1,2,5} B[] = {2,4,15} Output: 0 Explanation: A[] and B[] have only one common value. code:  bool check(vector<ll> A, vector<ll> B, int N) {         //code here         map<ll,ll> map1;         map<ll,ll> map2;                           for(ll ele:A)       ...

problem no 65: check if the string is isogram or not.

 problem: Given a string S of lowercase alphabets, check if it is isogram or not. An Isogram is a string in which no letter occurs more than once. Example 1: Input: S = machine Output: 1 Explanation: machine is an isogram as no letter has appeared twice. Hence we print 1. Example 2: Input: S = geeks Output: 0 Explanation: geeks is not an isogram as 'e' appears twice. Hence we print 0. Your Task: This is a function problem. You only need to complete the function  isIsogram()  that takes a string as a parameter and returns either true or false. code:  bool isIsogram(string s)     {         unordered_map<char,int> mapp;         for(char element:s)         {             mapp[element]++;         }        int flagforisogram=1;         for(auto ele:mapp)       ...

problem no 64: unique numbers

  In the given range [L, R], print all numbers having unique digits. e.g. In range 10 to 20 should print all numbers except 11. Example 1: Input: L = 10 R = 20 Output: 10 12 13 14 15 16 17 18 19 20 Explanation: The number 11 has two 1 therefore 11 is not a unique number. Example 2: Input: L = 1 R = 9 Output: 1 2 3 4 5 6 7 8 9 Explanation: All the Numbers are unique. Your Task:   You don't need to read input or print anything. Your task is to complete the function  uniqueNumbers () which takes two integers L and R as an input parameter and returns the list/vector of all the unique numbers present between L to R. code:  vector<int> uniqueNumbers(int L,int R)     {         vector<int> vec;         for(int i=L;i<=R;i++)         {             int num=i;             unordered_map<int,int> ma...

problem no 63: level order traversal.

Image
  Task A level-order traversal, also known as a breadth-first search, visits each level of a tree's nodes from left to right, top to bottom. You are given a pointer,  , pointing to the root of a binary search tree. Complete the  levelOrder  function provided in your editor so that it prints the level-order traversal of the binary search tree. Hint:  You'll find a queue helpful in completing this challenge. Function Description Complete the  levelOrder  function in the editor below. levelOrder  has the following parameter: -  Node pointer root : a reference to the root of the tree Prints - Print node.data items as space-separated line of integers. No return value is expected. Input Format The locked stub code in your editor reads the following inputs and assembles them into a BST: The first line contains an integer,   (the number of test cases). The   subsequent lines each contain an integer,  , denoting the value of a...

problem no 62:(problem on array):wave array.

problem:

problem no 61:(problem on strings):Check if strings are rotations of each other or not

 problem: Check if strings are rotations of each other or not Basic Accuracy: 49.96% Submissions: 13329 Points: 1 Given two strings s1 and s2. The task is to check if s2 is a rotated version of the string s1. The characters in the strings are in lowercase.

problem no 60:(problem on the matrix):printing the matrix in snake pattern

Image
 problem: Print Matrix in snake Pattern Basic Accuracy: 72.32% Submissions: 6635 Points: 1 Given a  matrix  of size N x N . Print the elements of the matrix in the snake like pattern depicted below. Example 1: Input : N = 3 matrix[][] = {{45, 48, 54},   {21, 89, 87}   {70, 78, 15}} Output : 45 48 54 87 89 21 70 78 15  Explanation : Matrix is as below: 45 48 54 21 89 87 70 78 15 Printing it in snake pattern will lead to the output as 45 48 54 87 89 21 70 78 15. Example 2: ...