Skip to content

varshitha1707/DailyCoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DAILY CODING

DAY 1:

TASK: Given a number N, print all numbers in the range from 1 to N having exactly 3 divisors.

https://www.geeksforgeeks.org/numbers-exactly-3-divisors/

My Solution: ClickHere

Expected Time Complexity: O(n^2/2)

Expected Auxiliary Space: O(1)

DAY 2:

TASK: Given two integers ‘a’ and ‘m’, find modular multiplicative inverse of ‘a’ under modulo ‘m’. The modular multiplicative inverse is an integer ‘x’ such that. a x ≅ 1 (mod m) The value of x should be in {0, 1, 2, … m-1}, i.e., in the range of integer modulo m.

https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/

My Solution: ClickHere

Expected Time Complexity: O(m)

Expected Auxiliary Space: O(1)

DAY 3:

TASK: Given an array of integers, find the first repeating element in it. We need to find the element that occurs more than once and whose index of first occurrence is smallest.

https://www.geeksforgeeks.org/find-first-repeating-element-array-integers/

My Solution: ClickHere

Expected Time Complexity: O(n^2-n)

Expected Auxiliary Space: O(1)

DAY 4:

TASK: Given an array arr[] of size n where every element is in range from 0 to n-1. Rearrange the given array so that arr[i] becomes arr[arr[i]]. This should be done with O(1) extra space.

https://www.geeksforgeeks.org/rearrange-given-array-place/

My Solution:ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 5:

TASK: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

https://www.geeksforgeeks.org/trapping-rain-water/

My Solution: ClickHere

Expected Time Complexity: O(n^2)

Expected Auxiliary Space: O(1)

DAY 6:

TASK: We are given two sorted arrays. We need to merge these two arrays such that the initial numbers (after complete sorting) are in the first array and the remaining numbers are in the second array. Extra space allowed in O(1).

https://www.geeksforgeeks.org/merge-two-sorted-arrays-o1-extra-space/

My Solution: ClickHere

Expected Time Complexity: O(n*m)

Expected Auxiliary Space: O(1)

DAY 7:

TASK: An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array at some pivot unknown to you beforehand. Devise a way to find an element in the rotated array in O(log n) time.

https://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/

My Solution: ClickHere

Expected Time Complexity: O(log(n))

Expected Auxiliary Space: O(1)

DAY 8:

TASK: Merge Sort is a Divide and Conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. The merge() function is used for merging two halves. Write the merge function along with the whole program.

https://www.geeksforgeeks.org/merge-sort/

My Solution: ClickHere

Expected Time Complexity: O(n) (Only for the merge() function)

Expected Auxiliary Space: O(n)

DAY 9:

TASK: Given two sorted arrays, find their union.

https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/

My Solution: ClickHere

Expected Time Complexity: O(n+m)

Expected Auxiliary Space: O(n+m)

DAY 10:

TASK: Given two sorted arrays, find their intersection.

https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/

My Solution: ClickHere

Expected Time Complexity: O(n+m)

Expected Auxiliary Space: O(n+m)

DAY 11:

TASK: Given an array of n distinct elements, find the minimum number of swaps required to sort the array.

https://www.geeksforgeeks.org/minimum-number-swaps-required-sort-array/

My Solution: ClickHere

Expected Time Complexity: O(nlogn)

Expected Auxiliary Space: O(n)

DAY 12:

TASK:Given an array “a[]” and integer “b”. Find whether b is present in a[] or not. If present, then double the value of b and search again. We repeat these steps until b is not found. Finally we return value of b.

geeksforgeeks.org/repeatedly-search-element-doubling-every-successful-search/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(n)

DAY 13:

TASK: Given arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required for the railway station so that no train waits.

https://www.geeksforgeeks.org/minimum-number-platforms-required-railwaybus-station/

My Solution: ClickHere

Expected Time Complexity: O(nlogn)

Expected Auxiliary Space: O(n)

DAY 14:

TASK:Given two sorted arrays, a[] and b[], the task is to find the median of these sorted arrays, in O(log n + log m) time complexity, when n is the number of elements in the first array, and m is the number of elements in the second array.

https://www.geeksforgeeks.org/median-of-two-sorted-arrays-of-different-sizes/

My Solution: ClickHere

Expected Time Complexity: O(n*m)

Expected Auxiliary Space: O(1)

DAY 15:

TASK: Given an array A[] consisting 0s, 1s and 2s. The task is to write a function that sorts the given array. The functions should put all 0s first, then all 1s and all 2s in last.

geeksforgeeks.org/sort-an-array-of-0s-1s-and-2s/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 16:

TASK: Perform arithmetic operations on 2 given matrices.

https://www.geeksforgeeks.org/different-operation-matrices/

My Solution: ClickHere

DAY 17:

TASK: Given an array of N elements, the task is to minimize the maximum difference of adjacent elements by inserting at most K elements in the array.

https://www.geeksforgeeks.org/minimize-the-maximum-difference-of-adjacent-elements-after-at-most-k-insertions/

My Solution: ClickHere

DAY 18:

TASK: Given a matrix of N size, the task is to find the determinant of the matrix.

https://www.geeksforgeeks.org/determinant-of-a-matrix/

My Solution: ClickHere

DAY 19:

TASK: Given a matrix of N size, the task is to find the transpose of the matrix.

https://www.geeksforgeeks.org/program-to-find-transpose-of-a-matrix/

My Solution: ClickHere

DAY 20:

TASK: Given a matrix of N size, the task is to rotate the matrix by 90 degrees without using extra space.

https://www.geeksforgeeks.org/rotate-a-matrix-by-90-degree-in-clockwise-direction-without-using-any-extra-space/

My Solution: ClickHere

DAY 21:

TASK: Given a 2D array, print it in spiral form.

https://www.geeksforgeeks.org/print-a-given-matrix-in-spiral-form/

My Solution: ClickHere

DAY 22:

TASK: Given an n x n matrix and a number x, find the position of x in the matrix if it is present in it. Otherwise, print “Not Found”. In the given matrix, every row and column is sorted in increasing order.

https://www.geeksforgeeks.org/search-in-row-wise-and-column-wise-sorted-matrix/

My Solution: ClickHere

DAY 23:

TASK: Given a binary matrix, find the maximum size rectangle binary-sub-matrix with all 1’s.

https://www.geeksforgeeks.org/maximum-size-rectangle-binary-sub-matrix-1s/

My Solution: ClickHere

DAY 24:

TASK: Given a number, find its corresponding Roman numeral.

https://www.geeksforgeeks.org/converting-decimal-number-lying-between-1-to-3999-to-roman-numerals/

My Solution: ClickHere

DAY 25:

TASK: Given a string containing lowercase characters. The task is to print the maximum occurring character in the input string. If 2 or more characters appear the same number of times, print the lexicographically (alphabetically) lowest (first) character.

geeksforgeeks.org/maximum-occurring-character-in-an-input-string-set-2/

My Solution: ClickHere

DAY 26:

TASK: Pangram is a sentence containing every letter in the English alphabet. Given a string, find all characters that are missing from the string, i.e., the characters that can make the string a Pangram. We need to print output in alphabetic order.

https://www.geeksforgeeks.org/missing-characters-make-string-pangram/

My Solution: ClickHere

DAY 27:

TASK: Write a program to Validate an IPv4 Address.

https://www.geeksforgeeks.org/program-to-validate-an-ip-address/

My Solution: ClickHere

DAY 28:

TASK: Given two strings s1 and s2, find if s1 is a substring of s2. If yes, return the index of the first occurrence, else return -1.

https://www.geeksforgeeks.org/check-string-substring-another/

My Solution: ClickHere

DAY 29:

TASK: Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2. And all occurrences of every character in ‘str1’ map to same character in ‘str2’

https://www.geeksforgeeks.org/check-if-two-given-strings-are-isomorphic-to-each-other/

My Solution: ClickHere

DAY 30:

TASK: Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1?

https://www.geeksforgeeks.org/a-program-to-check-if-strings-are-rotations-of-each-other/

My Solution: ClickHere

DAY 31:

TASK: Given a string str, find the length of the longest substring without repeating characters.

https://www.geeksforgeeks.org/length-of-the-longest-substring-without-repeating-characters/

My Solution: ClickHere

DAY 32:

TASK: Given two positive numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find product of these two numbers.

https://www.geeksforgeeks.org/multiply-large-numbers-represented-as-strings/

My Solution: ClickHere

DAY 33:

TASK: Write a function to check whether two given strings are anagram of each other or not.

https://www.geeksforgeeks.org/check-whether-two-strings-are-anagram-of-each-other/

My Solution: ClickHere

DAY 34:

TASK: Find Excel column name from a given column number.

https://www.geeksforgeeks.org/find-excel-column-name-given-number/

My Solution: ClickHere

DAY 35:

TASK: Reverse words in a given string.

https://www.geeksforgeeks.org/reverse-words-in-a-given-string/

My Solution: ClickHere

DAY 36:

TASK: Given a number n, check if k-th bit of n is set or not.

https://www.geeksforgeeks.org/check-whether-k-th-bit-set-not/

My Solution: ClickHere

DAY 37:

TASK: Given a positive integer, write a function to find if it is a power of two or not.

https://www.geeksforgeeks.org/program-to-find-whether-a-no-is-power-of-two/

My Solution: ClickHere

DAY 38:

TASK: A number is said to be a sparse number if in binary representation of the number no two or more consecutive bits are set. Write a function to check if a given number is Sparse or not.

https://www.geeksforgeeks.org/check-if-a-given-number-is-sparse-or-not/

My Solution: ClickHere

DAY 39:

TASK: Given two numbers ‘a’ and b’. Write a program to count number of bits needed to be flipped to convert ‘a’ to ‘b’.

https://www.geeksforgeeks.org/count-number-of-bits-to-be-flipped-to-convert-a-to-b/

My Solution: ClickHere

DAY 40:

TASK: Gray to Binary and Binary to Gray conversion.

https://www.geeksforgeeks.org/gray-to-binary-and-binary-to-gray-conversion/

My Solution: ClickHere

DAY 41:

TASK: Write a one line function to return position of first 1 from right to left, in binary representation of an Integer.

https://www.geeksforgeeks.org/position-of-rightmost-set-bit/

My Solution: ClickHere

DAY 42:

TASK: Given a positive integer n, count the total number of set bits in binary representation of all numbers from 1 to n.

https://www.geeksforgeeks.org/count-total-set-bits-in-all-numbers-from-1-to-n/

My Solution: ClickHere

DAY 43:

TASK: Given two numbers m and n. Find the position of the rightmost different bit in the binary representation of numbers. It is guaranteed that such a bit exists.

https://www.geeksforgeeks.org/position-rightmost-different-bit/

My Solution: ClickHere

DAY 44:

TASK: Given an set of positive integers. find the maximum XOR subset value in the given set. Expected time complexity O(n).

https://www.geeksforgeeks.org/find-maximum-subset-xor-given-set/

My Solution: ClickHere

DAY 45:

TASK: Swap all odd and even bits. Expected time complexity O(1).

https://www.geeksforgeeks.org/swap-all-odd-and-even-bits/

My Solution: ClickHere

DAY 46:

TASK: Check if two arrays are equal or not, using Hashing.

https://www.geeksforgeeks.org/check-if-two-arrays-are-equal-or-not/

My Solution: ClickHere

DAY 47:

TASK: Given an array with repeated elements, the task is to find the maximum distance two occurrences of an element.

https://www.geeksforgeeks.org/maximum-distance-two-occurrences-element-array/

My Solution: ClickHere

DAY 48:

TASK: Write a program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x.

https://www.geeksforgeeks.org/given-an-array-a-and-a-number-x-check-for-pair-in-a-with-sum-as-x/

My Solution: ClickHere

DAY 49:

TASK: Print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first.

https://www.geeksforgeeks.org/sort-elements-by-frequency/

My Solution: ClickHere

DAY 50:

TASK: Print ALL non-repeated elements of an array.

Similar to: https://www.geeksforgeeks.org/non-repeating-element/

My Solution: ClickHere

DAY 51:

TASK: Given an array, print all subarrays in the array which has sum 0.

https://www.geeksforgeeks.org/print-all-subarrays-with-0-sum/

My Solution: ClickHere

DAY 52:

TASK: Find k numbers with most occurrences in the given array.

https://www.geeksforgeeks.org/find-k-numbers-occurrences-given-array/

My Solution: ClickHere

DAY 53:

TASK: Sort an array according to the order defined by another array

https://www.geeksforgeeks.org/sort-array-according-order-defined-another-array/

My Solution: ClickHere

DAY 54:

TASK: Given an array of integers, find the length of the longest sub-array with sum equals to 0.

https://www.geeksforgeeks.org/find-the-largest-subarray-with-0-sum/

My Solution: ClickHere

DAY 55:

TASK: Given an array of integers, find anyone combination of four elements in the array whose sum is equal to a given value X.

https://www.geeksforgeeks.org/find-four-elements-that-sum-to-a-given-value-set-2/

My Solution: ClickHere

DAY 56:

TASK: Given an array of size n and an integer k, return the count of distinct numbers in all windows of size k.

https://www.geeksforgeeks.org/count-distinct-elements-in-every-window-of-size-k/

My Solution: ClickHere

DAY 57:

TASK: Print all elements of a Linked List where we take linked list as input and print the linked list in a single line.

My Solution: ClickHere

Expected Time Complexity : O(N)

Expected Auxiliary Space : O(1)

DAY 58:

TASK: Given pointer to the head node of a linked list, the task is to reverse the linked list. We need to reverse the list by changing the links between nodes.

https://www.geeksforgeeks.org/reverse-a-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 59:

TASK: Given a singly linked list and a key, count number of occurrences of given key in linked list.

https://www.geeksforgeeks.org/write-a-function-that-counts-the-number-of-times-a-given-int-occurs-in-a-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 60:

TASK: Given a singly linked list, write a function to swap elements pairwise.

https://www.geeksforgeeks.org/pairwise-swap-elements-of-a-given-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 61:

TASK: Given two numbers represented by two linked lists, write a function that returns the sum list. The sum list is linked list representation of the addition of two input numbers. It is not allowed to modify the lists. Also, not allowed to use explicit extra space (Hint: Use Recursion).

https://www.geeksforgeeks.org/sum-of-two-linked-lists/

My Solution: ClickHere

Expected Time Complexity: O(n+m)

Expected Auxiliary Space: O(max(n,m)

DAY 62:

TASK: Write a function to insert a new value in a sorted Circular Linked List (CLL). For example, if the input CLL is following.

https://www.geeksforgeeks.org/sorted-insert-for-circular-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 63:

TASK: Split a Circular Linked List into two halves.

https://www.geeksforgeeks.org/split-a-circular-linked-list-into-two-halves/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 64:

TASK: Given a linked list, write a function to reverse every k nodes (where k is an input to the function).

https://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 65:

TASK: Given a linked list, check if the linked list has loop or not. Below diagram shows a linked list with a loop.

https://www.geeksforgeeks.org/detect-loop-in-a-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 66:

TASK: Write a function to get the intersection point of two Linked Lists.

https://www.geeksforgeeks.org/write-a-function-to-get-the-intersection-point-of-two-linked-lists/

My Solution: ClickHere

Expected Time Complexity: O(n+m)

Expected Auxiliary Space: O(1)

DAY 67:

TASK: Given a singly linked list, delete middle of the linked list. For example, if given linked list is 1->2->3->4->5 then linked list should be modified to 1->2->4->5.

https://www.geeksforgeeks.org/delete-middle-of-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 68:

TASK: Clone a linked list with next and random pointer.

https://www.geeksforgeeks.org/a-linked-list-with-next-and-arbit-pointer/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 69:

TASK: QuickSort on Singly Linked List.

https://www.geeksforgeeks.org/quicksort-on-singly-linked-list/

My Solution: ClickHere

DAY 70:

TASK:

Given a Circular Linked List. The task is to write programs to delete nodes from this list present at: First position. Last Position. At any given position i.

https://www.geeksforgeeks.org/deletion-at-different-positions-in-a-circular-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 71:

TASK: QuickSort on Doubly Linked List

https://www.geeksforgeeks.org/quicksort-for-linked-list/

My Solution: ClickHere

Expected Time Complexity: O(nlog(n))

Expected Auxiliary Space: O(1)

DAY 72:

TASK: Delete a Node from linked list without head pointer.

https://www.geeksforgeeks.org/delete-a-node-from-linked-list-without-head-pointer/

My Solution: ClickHere

Expected Time Complexity: O(1)

Expected Auxiliary Space: O(1)

DAY 73:

TASK: Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort.

https://www.geeksforgeeks.org/merge-sort-for-doubly-linked-list/

My Solution: ClickHere

DAY 74:

TASK: Reverse a string using stack.

https://www.geeksforgeeks.org/stack-set-3-reverse-string-using-stack/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(n)

DAY 75:

TASK: Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in array. Elements for which no greater element exist, consider next greater element as -1. The next greater elements should be printed in same order as input array.

https://www.geeksforgeeks.org/next-greater-element-in-same-order-as-input/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(n)

DAY 76:

TASK: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the SpecialStack. All these operations of SpecialStack must be O(1).

https://www.geeksforgeeks.org/design-a-stack-that-supports-getmin-in-o1-time-and-o1-extra-space/

My Solution: ClickHere

Expected Time Complexity: O(1)

Expected Auxiliary Space: O(1)

DAY 77:

TASK: The Postfix notation is used to represent algebraic expressions. The expressions written in postfix form are evaluated faster compared to infix notation as parenthesis are not required in postfix.

https://www.geeksforgeeks.org/stack-set-4-evaluation-postfix-expression/#:~:text=The%20expressions%20written%20in%20postfix,are%20not%20required%20in%20postfix.&text=Following%20is%20algorithm%20for%20evaluation,following%20for%20every%20scanned%20element

My Solution: ClickHere

Expected Time Complexity: O(|s|)

Expected Auxiliary Space: O(|s|)

DAY 78:

TASK: Given a binary matrix, find the maximum size rectangle binary-sub-matrix with all 1’s.

https://www.geeksforgeeks.org/maximum-size-rectangle-binary-sub-matrix-1s/

My Solution: ClickHere

Expected Time Complexity : O(n*m)

Expected Auixiliary Space : O(m)

DAY 79:

TASK: Given a stack, sort it using recursion. Use of any loop constructs like while, for..etc is not allowed. We can only use the following ADT functions on Stack S:

is_empty(S) : Tests whether stack is empty or not. push(S) : Adds new element to the stack. pop(S) : Removes top element from the stack. top(S) : Returns value of the top element. Note that this function does not remove element from the stack.

https://www.geeksforgeeks.org/sort-a-stack-using-recursion/

My Solution: ClickHere

Expected Time Complexity : O(n*n)

Expected Auixiliary Space : O(n)

DAY 80:

TASK: Largest Rectangular Area in a Histogram.

https://www.geeksforgeeks.org/largest-rectangle-under-histogram/

My Solution: ClickHere

Expected Time Complexity : O(n)

Expected Auixiliary Space : O(n)

DAY 81:

TASK: Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correct in exp.

https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/

My Solution: ClickHere

Expected Time Complexity : O(|x|)

Expected Auixiliary Space : O(|x|)

DAY 82:

TASK: Find maximum of minimum for every window size in a given array.

https://www.geeksforgeeks.org/find-the-maximum-of-minimums-for-every-window-size-in-a-given-array/

My Solution: ClickHere

Expected Time Complexity : O(n)

Expected Auixiliary Space : O(n)

DAY 83:

TASK: The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock’s price for all n days. The span Si of the stock’s price on a given day i is defined as the maximum number of consecutive days just before the given day, for which the price of the stock on the current day is less than or equal to its price on the given day.

https://www.geeksforgeeks.org/the-stock-span-problem/

My Solution: ClickHere

Expected Time Complexity : O(n)

Expected Auixiliary Space : O(n)

DAY 84:

TASK: Convert an infix expression to a Postfix expression

https://www.geeksforgeeks.org/stack-set-2-infix-to-postfix/

My Solution: ClickHere

Expected Time Complexity : O(|x|)

Expected Auixiliary Space : O(|x|)

DAY 85:

TASK: Given a number n, write a function that generates and prints all binary numbers with decimal values from 1 to n.

https://www.geeksforgeeks.org/interesting-method-generate-binary-numbers-1-n/

My Solution: ClickHere

Expected Time Complexity : O(Nlog2N)

Expected Auixiliary Space : O(Nlog2N)

DAY 86:

TASK: Write the functions push() and pop() for a queue.

https://www.geeksforgeeks.org/queuepush-and-queuepop-in-cpp-stl/

My Solution: ClickHere

Expected Time Complexity : O(n)

Expected Auixiliary Space : O(n)

DAY 87:

TASK: We are given a Queue data structure that supports standard operations like enqueue() and dequeue(). We need to implement a Stack data structure using only instances of Queue and queue operations allowed on the instances.

https://www.geeksforgeeks.org/implement-stack-using-queue/

My Solution: ClickHere

Expected Time Complexity: O(1) for push() and O(N) for pop() (or vice-versa).

Expected Auxiliary Space: O(1) for both push() and pop().

DAY 88:

TASK: Queue using Circular Array (Push and pop operations in a circular queue using array)

https://www.geeksforgeeks.org/circular-queue-set-1-introduction-array-implementation/

My Solution: ClickHere

DAY 89:

TASK: Given an integer k and a queue of integers, we need to reverse the order of the first k elements of the queue, leaving the other elements in the same relative order.

https://www.geeksforgeeks.org/reversing-first-k-elements-queue/

My Solution: ClickHere

Expected Time Complexity : O(n+k)

Expected Auixiliary Space : O(n)

DAY 90:

TASK: We are given a stack data structure with push and pop operations, the task is to implement a queue using instances of stack data structure and operations on them.

https://www.geeksforgeeks.org/queue-using-stacks/

My Solution: ClickHere

Expected Time Complexity: O(1) for push() and O(N) for pop() (or vice-versa).

Expected Auxiliary Space: O(1) for both push() and pop().

DAY 91:

TASK: Sliding Window Maximum (Maximum of all subarrays of size k)

https://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(n)

DAY 92:

TASK: Given a square chessboard of N x N size, the position of Knight and position of a target is given. We need to find out the minimum steps a Knight will take to reach the target position.

https://www.geeksforgeeks.org/minimum-steps-reach-target-knight/

My Solution: ClickHere

Expected Time Complexity: O(n^2)

Expected Auxiliary Space: O(n^2)

DAY 93:

TASK: Given two sorted arrays. There is only 1 difference between the arrays. The first array has one element extra added in between. Find the index of the extra element.

https://www.geeksforgeeks.org/find-index-of-an-extra-element-present-in-one-sorted-array/

My Solution: ClickHere

Expected Time Complexity: O(logn)

Expected Auxiliary Space: O(1)

DAY 94:

TASK: Given a matrix of N rows and M columns, consist of 0’s and 1’s. The task is to find the perimeter of subfigure consisting only 1’s in the matrix. Perimeter of single 1 is 4 as it can be covered from all 4 side. Perimeter of double 11 is 6.

https://www.geeksforgeeks.org/find-perimeter-shapes-formed-1s-binary-matrix/

My Solution: ClickHere

DAY 95:

TASK: Given two linked lists(can be sorted or unsorted) of size n and m 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.

https://www.geeksforgeeks.org/count-pairs-two-linked-lists-whose-sum-equal-given-value/

My Solution: ClickHere

Expected Time Complexity: O(n+m)

Expected Auxiliary Space: O(n+m)

DAY 96:

TASK: Given a linked list, task is to make a function which check whether the length of linked list is even or odd.

https://www.geeksforgeeks.org/check-whether-the-length-of-given-linked-list-is-even-or-odd/

My Solution: ClickHere

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(1)

DAY 97:

TASK: Given a string str and another string patt. Find the character in patt that is present at the minimum index in str. If no character of patt is present in str then print ‘No character present’.

https://www.geeksforgeeks.org/find-character-first-string-present-minimum-index-second-string/

My Solution: ClickHere

Expected Time Complexity: O(max(|str|, |patt|))

Expected Auxilary Space: O(K) where K <= 26

DAY 98:

TASK: Program to count leaf nodes in a binary tree.

https://www.geeksforgeeks.org/write-a-c-program-to-get-count-of-leaf-nodes-in-a-binary-tree/

My Solution: ClickHere

DAY 99:

TASK: Given a Binary Tree, print Right view of it. Right view of a Binary Tree is set of nodes visible when tree is visited from Right side.

https://www.geeksforgeeks.org/right-view-binary-tree-using-queue/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 100:

TASK: Given two Binary Trees, write a function that returns true if two trees are mirror of each other, else false. For example, the function should return true for following input trees.

https://www.geeksforgeeks.org/check-if-two-trees-are-mirror/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 101:

TASK: The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. The diagram below shows two trees each with diameter nine, the leaves that form the ends of the longest path are shaded (note that there is more than one path in each tree of length nine, but no path longer than nine nodes).

https://www.geeksforgeeks.org/diameter-of-a-binary-tree/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 102:

TASK: Write a function that returns true if the given Binary Tree is SumTree else false. A SumTree is a Binary Tree where the value of a node is equal to the sum of the nodes present in its left subtree and right subtree. An empty tree is SumTree and the sum of an empty tree can be considered as 0. A leaf node is also considered as SumTree.

https://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-sumtree/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 103:

TASK: Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7.

https://www.geeksforgeeks.org/level-order-traversal-in-spiral-form/

My Solution: ClickHere

Expected Time Complexity: O(N^2).

Expected Auxiliary Space: O(Height of the Tree).

DAY 104:

TASK: Write a function to print ZigZag order traversal of a binary tree. For the below binary tree the zigzag order traversal will be 1 3 2 7 6 5 4.

https://www.geeksforgeeks.org/zigzag-tree-traversal/

My Solution: ClickHere

Expected Time Complexity: O(N^2).

Expected Auxiliary Space: O(Height of the Tree).

DAY 105:

TASK: Given a Binary Tree with all unique values and two nodes value n1 and n2. The task is to find the lowest common ancestor of the given two nodes. We may assume that either both n1 and n2 are present in the tree or none of them is present.

https://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 106:

TASK: To identify if two trees are identical, we need to traverse both trees simultaneously, and while traversing we need to compare data and children of the trees.

https://www.geeksforgeeks.org/write-c-code-to-determine-if-two-trees-are-identical/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 107:

TASK: Given a binary tree and a number, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals the given number. Return false if no such path can be found.

https://www.geeksforgeeks.org/root-to-leaf-path-sum-equal-to-a-given-number/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(Height of the Tree).

DAY 108:

TASK: Given a Binary Tree, find the vertical sum of the nodes that are in the same vertical line. Print all sums through different vertical lines.

https://www.geeksforgeeks.org/vertical-sum-in-a-given-binary-tree/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(N).

DAY 109:

TASK: Given a binary tree in which nodes are numbered from 1 to n. Given a node and a positive integer K. We have to print the Kth ancestor of the given node in the binary tree. If there does not exist any such ancestor then print -1.

https://www.geeksforgeeks.org/kth-ancestor-node-binary-tree-set-2/

My Solution: ClickHere

Expected Time Complexity: O(N).

Expected Auxiliary Space: O(N).

DAY 110:

TASK: Write a function to detect if two trees are isomorphic. Two trees are called isomorphic if one of them can be obtained from other by a series of flips, i.e. by swapping left and right children of a number of nodes.

https://www.geeksforgeeks.org/tree-isomorphism-problem/

My Solution: ClickHere

Expected Time Complexity: O(min(M, N)) where M and N are the sizes of the two trees.

Expected Auxiliary Space: O(min(H1, H2)) where H1 and H2 are the heights of the two trees.

DAY 111:

TASK: Given a binary tree, write a function that returns true if the tree satisfies below property. For every node, data value must be equal to sum of data values in left and right children. Consider data value as 0 for NULL children.

https://www.geeksforgeeks.org/check-for-children-sum-property-in-a-binary-tree/

My Solution: ClickHere

Expected Time Complexiy: O(N).

Expected Auxiliary Space: O(Height of the Tree)

DAY 114:

TASK: Iterative inorder, preorder, postorder traversal in a binary tree

My Solution: ClickHere

DAY 115:

TASK: Recursive inorder, preorder, postorder traversal in a binary tree

My Solution: ClickHere

Releases

No releases published

Packages

No packages published

Languages