Posts

  Count numbers containing 4   Basic  Accuracy:   48.18%  Submissions:   2010  Points:   1 Count the numbers between 1 to  N  containing 4 as a digit.   Example 1: Input: N = 9 Output: 1 Explanation: 4 is the only number between 1 to 9 which contains 4 as a digit. Example 2: Input: N = 14 Output: 2 Explanation: 4 and 14 are the only number between 1 to 14 that contains 4 as a digit.   Your Task: You don't need to read input or print anything. Your task is to complete the function  countNumberswith4()  which takes an Integer N as input and returns the answer.

heck if array contains contiguous integers with duplicates allowed

Easy  Accuracy:   65.11%  Submissions:   761  Points:   2 Given an array of n integers(duplicates allowed). Print “Yes” if it is a set of contiguous integers else print “No”. Example 1: ​ Input : arr[ ] = {5, 2, 3, 6, 4, 4, 6, 6} Output : Yes Explanation: The elements  of array form a contiguous set of integers which is {2, 3, 4, 5, 6} so the output is "Yes". Example 2: Input : arr[ ] = {10, 14, 10, 12, 12,  13, 15} Output : No Your Task: This is a function problem. The input is already taken care of by the driver code. You only need to complete the function  areElementsContiguous()  that takes an array  (arr) , sizeOfArray  (n) , and return the  true  if it is a set of contiguous integers else print  false . The driver code takes care of the printing.

Delete without head pointer

You are given a pointer/ reference to the node which is to be deleted from the linked list of   N  nodes. The task is to delete the node. Pointer/ reference to head node is not given.  Note:  No head reference is given to you. It is guaranteed that the node to be deleted is   not a tail node   in the linked list. Example 1: Input: N = 2 value[] = {1,2} node = 1 Output: 2 Explanation: After deleting 1 from the linked list, we have remaining nodes as 2. Example 2: Input: N = 4 value[] = {10,20,4,30} node = 20 Output: 10 4 30 Explanation: After deleting 20 from the linked list, we have remaining nodes as 10, 4 and 30. Your Task: You only need to complete the  function deleteNode  that takes  reference  to the node that needs to be  deleted . The  printing  is done  automatically  by the  driver code .

Sum of Big Integers

Given two positive integers   X   and   Y . You have to add two integers and output their   sum .   Example 1: Input: X = 3, Y = 4 Output: 7 Explanation: Sum of X and Y is 7   Example 2: Input: X = 8, Y = 2 Output: 10 Explanation: Sum of X and Y is 10.   Your Task: Your task is to complete the function  add () which accepts BigIntegers x and y as input parameters, and returns their sum.

Find smallest values of x and y

Given two values   ‘a’   and   ‘b’   that represent coefficients in “ ax – by = 0 ”, find the smallest values of x and y that satisfy the equation. It may also be assumed that x > 0, y > 0, a > 0 and b > 0. Example 1: Input: a = 25, b = 35 Output: 7 5 Explaination: 25*7 - 35*5 = 0. And x = 7 and y = 5 are the least possible values of x and y to get the equation solved. Example 2: Input: a = 3, b = 7 Output: 7 3 Explaination: For this case x = 7 and y = 3 are the least values of x and y to satisfy the equation. Your Task: You do not need to read input or print anything. Your task is to complete the function  findXY()  which takes a and b as input parameters and returns the least possible values of x and y to satisfy the equation.

Repeated sum of digits

Given an integer N, recursively sum digits of N until we get a single digit.  The process can be described below If N < 10 digSum(N) = N Else digSum(N) = Sum(digSum(N))   Example 1: Input: N = 1234 Output: 1 Explanation: The sum of 1+2+3+4 = 10, digSum(x) == 10 Hence ans will be 1+0 = 1     Example 2: Input: N = 9999 Output: 9 Explanation: Check it yourself.   Your Task: You don't need to read input or print anything. Your task is to complete the function repeatedSumOfDigits() which takes an integer N and returns the repeated sum of digits of N.

occurrence 2 as a gidit

 x=0 for i in range(23):     x+=str(i).count('2') print(x)

Expression Tree

Given a full binary expression tree consisting of basic binary operators (+ , – ,*, /) and some integers, Your task is to evaluate the expression tree. Example 1: Input: + / \ * - / \ / \ 5 4 100 20 Output: 100 Explanation: ((5 * 4) + (100 - 20)) = 100 Example 2: Input: - / \ 4 7 Output: -3 Explanation: 4 - 7 = -3 Your Task:   You dont need to read input or print anything. Complete the function  evalTree()  which takes root node as input parameter and returns an integer denoting the result obtained by simplifying the expression tree. Expected Time Complexity:  O(N)

Count pairs from two linked lists whose sum is equal to a given value

Difficulty Level :   Easy Last Updated :   07 Jan, 2021 Given two linked lists(can be sorted or unsorted) of size  n1  and  n2  of distinct elements. Given a value  x . The problem is to count all pairs from both lists whose sum is equal to the given value  x . Note:  The pair has an element from each linked list. Examples:    Input : list1 = 3->1->5->7 list2 = 8->2->5->3 x = 10 Output : 2 The pairs are: (5, 5) and (7, 3) Input : list1 = 4->3->5->7->11->2->1 list2 = 2->3->4->5->6->8-12 x = 9 Output : 5 # Python3 implementation to count pairs from both linked # lists whose sum is equal to a given value # A Linked list node class Node: def __init__(self,data): self.data = data self.next = None # function to insert a node at the # beginning of the linked list def push(head_ref,new_data): new_node=Node(new_data) #new_node.data = new_...

Trie | (Insert and Search)

Trie is an efficient information retrieval data structure. Use this data structure to store Strings and search strings. Your task is to use TRIE data structure and search the given string A. If found print 1 else 0. Example 1: Input: N = 8 key[] = {the,a,there,answer,any,by,   bye,their} search = the Output: 1 Explanation: the is present in the given string "the a there answer any by bye their" Example 2: Input: N = 8 key[] = {the,a,there,answer,any,by,   bye,their} search = geeks Output: 0 Explanation: geeks is not present in the given string "the a there answer any by bye their" Your Task: Complete  insert  and  search  function and return  true  if key is present in the formed trie else  false  in the search function. (In case of true, 1 is printed and false, 0 is printed by the driver's code. Expected Time Complexity:  O(M+|search|). Expected Auxiliary Space:  O(M). M = sum of the length of all strings...