GeeksforGeeks
17.4K subscribers
1.83K photos
34 videos
24 files
2.76K links
Official Hub βœ…

Your coding haven – where tech meets simplicity.

Discover:
πŸ˜‚ Coding Laughter
πŸ“˜ Curated Study Material
πŸ’Ž Exclusive Offers

Utilize every service we provide and make a promise to find better opportunities for yourself! #gfgkarlohojayega!
Download Telegram
Problem Of The Day
"Reverse a Linked List in groups of given size"

Given a linked list of size N. The task is to reverse every k nodes (where k is an input to the function) in the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should be considered as a group and must be reversed (See Example 2 for clarification).

Example 1:

Input:
LinkedList: 1->2->2->4->5->6->7->8
K = 4
Output: 4 2 2 1 8 7 6 5
Explanation:
The first 4 elements 1,2,2,4 are reversed first
and then the next 4 elements 5,6,7,8. Hence, the
resultant linked list is 4->2->2->1->8->7->6->5.

Example 2:

Input:
LinkedList: 1->2->3->4->5
K = 3
Output: 3 2 1 5 4
Explanation:
The first 3 elements are 1,2,3 are reversed
first and then elements 4,5 are reversed.Hence,
the resultant linked list is 3->2->1->5->4.

Your Task:
You don't need to read input or print anything. Your task is to complete the function reverse() which should reverse the linked list in group of size k and return the head of the modified linked list.

Expected Time Complexity : O(N)
Expected Auxilliary Space : O(1)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/reverse-a-linked-list-in-groups-of-given-size/1
πŸ‘3
Coding is one the essential skills that should be introduced to students early. However, the complications of education system doesn't do so.

In webinar, our expert will highlight the importance of introducing coding and problem-solving abilities at an early age.

Link - https://bit.ly/3pOc1yI
Must Learn!πŸ’‘
With ChatGPT taking Content Writing and everything around it by storm, it is increasingly becoming important to also understand how to put it to best use. This is where Prompt Engineering comes into the picture.

In this article, we discuss 5 ChatGpt Prompt Engineering Principles that will help you to write the best prompts and complete all your content tasks with the help of ChatGPT more effectively.

Link- https://www.geeksforgeeks.org/chatgpt-prompt-engineering-principles/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘1
🚨Job Alert🚨
NEC Corporation is hiring for Cyber Security.

Location - Noida / Bangalore
Experience - Upto 2 Years
Apply by - Aug 20, 2023

Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/nec-corporation-cyber-security?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Problem Of The Day
"Remove duplicates from an unsorted linked list"

Given an unsorted linked list of N nodes. The task is to remove duplicate elements from this unsorted Linked List. When a value appears in multiple nodes, the node which appeared first should be kept, all others duplicates are to be removed.

Example 1:

Input:
N = 4
value[] = {5,2,2,4}
Output: 5 2 4
Explanation:Given linked list elements are
5->2->2->4, in which 2 is repeated only.
So, we will delete the extra repeated
elements 2 from the linked list and the
resultant linked list will contain 5->2->4

Example 2:

Input:
N = 5
value[] = {2,2,2,2,2}
Output: 2
Explanation:Given linked list elements are
2->2->2->2->2, in which 2 is repeated. So,
we will delete the extra repeated elements
2 from the linked list and the resultant
linked list will contain only 2.

Your Task:
You have to complete the method removeDuplicates() which takes 1 argument: the head of the linked list. Your function should return a pointer to a linked list with no duplicate element.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/remove-duplicates-from-an-unsorted-linked-list/1
πŸ‘4
The world where we live in today, change is the only constant. This is applicable for organisations as well.

So, how ogranisations can transformed for continuos innovation? Learn from our experts in the 'DevOps Mindset | Transforming Organizations for Continuous Innovation.

Link- https://bit.ly/43BpvLO
πŸ‘1
Problem Of The Day
"Given a linked list of 0s, 1s and 2s, sort it."

Given a linked list of N nodes where nodes can contain values 0s, 1s, and 2s only. The task is to segregate 0s, 1s, and 2s linked list such that all zeros segregate to head side, 2s at the end of the linked list, and 1s in the mid of 0s and 2s.

Example 1:

Input:
N = 8
value[] = {1,2,2,1,2,0,2,2}
Output: 0 1 1 2 2 2 2 2
Explanation: All the 0s are segregated
to the left end of the linked list,
2s to the right end of the list, and
1s in between.

Example 2:

Input:
N = 4
value[] = {2,2,0,1}
Output: 0 1 2 2
Explanation: After arranging all the
0s,1s and 2s in the given format,
the output will be 0 1 2 2.

Your Task:
The task is to complete the function segregate() which segregates the nodes in the linked list as asked in the problem statement and returns the head of the modified linked list. The printing is done automatically by the driver code.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/given-a-linked-list-of-0s-1s-and-2s-sort-it/1
Problem Of The Day
"Right View of Binary Tree."

Given a Binary Tree, find Right view of it. Right view of a Binary Tree is set of nodes visible when tree is viewed from right side.

Right view of following tree is 1 3 7 8.

1
/ \
2 3
/ \ / \
4 5 6 7
\
8

Example 1:

Input:
1
/ \
3 2
Output: 1 2
Example 2:

Input:
10
/ \
20 30
/ \
40 60
Output: 10 30 60
Your Task:
Just complete the function rightView() that takes node as parameter and returns the right view as a list.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/right-view-of-binary-tree/1
Must Learn!πŸ’‘
Node.js and Web browsers are two different but interrelated technologies in web development. JavaScript is executed in both the environment, node.js, and browser but for different use cases.

In this article, we will see why to differentiate both and some of the top differences between Node.js and Browser, that every developer should know. But before that let’s first understand what is node.js and the browser.

Link- https://www.geeksforgeeks.org/nodejs-vs-browser/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
🚨Job Alert🚨
Lenovo is hiring for Front End Developer.

Location - Bengaluru, Karnataka
Experience - 3 - 5 Years
Apply by - Aug 31, 2023

Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/frontenddeveloper-lenovo?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘1
Problem Of The Day
"Level order traversal in spiral form"

Given a binary tree and the task is to find the spiral order traversal of the tree.

Spiral order Traversal mean: Starting from level 0 for root node, for all the even levels we print the node's value from right to left and for all the odd levels we print the node's value from left to right.

For below tree, function should return 1, 2, 3, 4, 5, 6, 7.





Example 1:

Input:
1
/ \
3 2
Output:1 3 2

Example 2:

Input:
10
/ \
20 30
/ \
40 60
Output: 10 20 30 60 40

Your Task:
The task is to complete the function findSpiral() which takes root node as input parameter and returns the elements in spiral form of level order traversal as a list. The newline is automatically appended by the driver code.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/level-order-traversal-in-spiral-form/1
πŸ‘1
Must Learn!πŸ’‘
Do you struggle with the thought of whether to focus on Data Structures and Algorithms or perform hands-on development?

Well, you are not alone! This article will help you understand the right steps by analyzing both topics. Give it a read.

Link - https://www.geeksforgeeks.org/how-to-manage-dsa-and-development-together/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘1
Problem Of The Day
"Kth Ancestor in a Tree"

Given a binary tree of size N, a node, and a positive integer k., Your task is to complete the function kthAncestor(), the function should return the kth ancestor of the given node in the binary tree. If there does not exist any such ancestor then return -1.
Note: It is guaranteed that the node exists in the tree.

Example 1:

Input:
K = 2 Node = 4
Output: 1
Explanation:
Since, K is 2 and node is 4, so we
first need to locate the node and
look k times its ancestors.
Here in this Case node 4 has 1 as his
2nd Ancestor aka the Root of the tree.

Example 2:

Input:
k=1
node=3
1
/ \
2 3

Output:
1
Explanation:
K=1 and node=3 ,Kth ancestor of node 3 is 1.

Your Task:
You are asked to complete the function kthAncestor() which accepts root of the tree, k and node as input parameters, and returns the kth ancestor of Node which contains node as its value.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/kth-ancestor-in-a-tree/1
πŸ‘3
Must Learn!πŸ’‘
Documentation is written data or instructions that outline a certain problem statement, approaches, functionality, workflow, architecture, challenges, and development process.

Documentations can be used to gain a comprehensive understanding of the solution’s functionality, installation, and configurations at once.

In this article, you will get the significance of a documentation process and 10 tips and best practices to write better documentation. This article will also touch upon recommended tools and websites for creating good documentation.

Link- https://www.geeksforgeeks.org/best-practices-for-writing-documentation/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘1
🚨 Job Alert 🚨
Air India is hiring for Front End Developer.

Location - Kochi, Kerala
Experience - 2 - 4 Years
Apply by - Aug 31, 2023

Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/frontenddeveloper-airindia?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘2πŸ”₯1
Problem Of The Day
"Heap Sort"

Given an array of size N. The task is to sort the array elements by completing functions heapify() and buildHeap() which are used to implement Heap Sort.

Example 1:

Input:
N = 5
arr[] = {4,1,3,9,7}
Output:
1 3 4 7 9
Explanation:
After sorting elements
using heap sort, elements will be
in order as 1,3,4,7,9.

Example 2:

Input:
N = 10
arr[] = {10,9,8,7,6,5,4,3,2,1}
Output:
1 2 3 4 5 6 7 8 9 10
Explanation:
After sorting elements
using heap sort, elements will be
in order as 1, 2,3,4,5,6,7,8,9,10.

Your Task :
You don't have to read input or print anything. Your task is to complete the functions heapify(), buildheap() and heapSort() where heapSort() and buildheap() takes the array and it's size as input and heapify() takes the array, it's size and an index i as input. Complete and use these functions to sort the array using heap sort algorithm.

Note: You don't have to return the sorted list. You need to sort the array "arr" in place.

Expected Time Complexity: O(N * Log(N)).
Expected Auxiliary Space: O(1).

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/heap-sort/1
πŸ‘5
Must Learn! πŸ’‘
Are you a tech enthusiast who is excited to work on some innovative projects or simply wants to enhance your resume? Then participating in the hackathon is the best option for you.

It will not only help you to showcase your talent but also collaborate with other tech enthusiasts. Further hackathons provide exposure to learning the latest technologies as well.

In this article, we will discuss in detail the top hackathons for beginners. We will also cover what are a hackathon, its benefits, and the working of the hackathon. So let’s get started.

Link- https://www.geeksforgeeks.org/hackathons-for-beginners/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘1
Problem Of The Day
"Lowest Common Ancestor in a BST"

Given a Binary Search Tree (with all values unique) and two node values n1 and n2 (n1!=n2). Find the Lowest Common Ancestors of the two nodes in the BST.

Example 1:

Input:
5
/ \
4 6
/ \
3 7
\
8
n1 = 7, n2 = 8
Output: 7

Example 2:

Input:
2
/ \
1 3
n1 = 1, n2 = 3
Output: 2

Your Task:
You don't need to read input or print anything. Your task is to complete the function LCA() which takes the root Node of the BST and two integer values n1 and n2 as inputs and returns the Lowest Common Ancestor of the Nodes with values n1 and n2 in the given BST.

Expected Time Complexity: O(Height of the BST).
Expected Auxiliary Space: O(Height of the BST).

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-bst/1
πŸ‘2
🚨Job Alert🚨
HP is hiring for Data engineer.

Location - Bengaluru, Karnataka, India (Hybrid)
Experience - 10 - 15 Years
Apply by - Aug 25, 2023

Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/hp-data-eng?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
πŸ‘2
Problem Of The Day
"Median of BST"

Given a Binary Search Tree of size N, find the Median of its Node values.

Example 1:

Input:
6
/ \
3 8
/ \ / \
1 4 7 9
Output: 6
Explanation: Inorder of Given BST will be:
1, 3, 4, 6, 7, 8, 9. So, here median will 6.

Example 2:

Input:
6
/ \
3 8
/ \ /
1 4 7
Output: 5
Explanation:Inorder of Given BST will be:
1, 3, 4, 6, 7, 8. So, here median will
(4 + 6)/2 = 10/2 = 5.

Your Task:
You don't need to read input or print anything. Your task is to complete the function findMedian() which takes the root of the Binary Search Tree as input and returns the Median of Node values in the given BST.
Median of the BST is:

If number of nodes are even: then median = (N/2 th node + (N/2)+1 th node)/2
If number of nodes are odd : then median = (N+1)/2th node.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/median-of-bst/1
❀3πŸ‘1