GeeksforGeeks
19.1K subscribers
1.66K photos
34 videos
24 files
2.63K 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
"Valid Compressed String"

Solve the problem to win points

A special compression mechanism can arbitrarily delete 0 or more characters and replace them with the deleted character count.
Given two strings, S and T where S is a normal string and T is a compressed string, determine if the compressed string T is valid for the plaintext string S.


Example 1:

Input:
S = "GEEKSFORGEEKS"
T = "G7G3S"
Output:
1
Explanation:
We can clearly see that T is a valid
compressed string for S.

Example 2:

Input:
S = "DFS"
T = "D1D"
Output :
0
Explanation:
T is not a valid compressed string.

Your Task:
You don't need to read input or print anything. Your task is to complete the function checkCompressed() which takes 2 strings S and T as input parameters and returns integer 1 if T is a valid compression of S and 0 otherwise.


Expected Time Complexity: O(|T|)
Expected Auxiliary Space: O(1)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/13eb74f1c80bc67d526a69b8276f6cad1b8c3401/1

Powered by hirist.com
πŸ‘1
🚨Job Alert🚨
Careers360 is hiring for Software Developer-Python.

Location - Gurgaon(Work from Office)
Experience - 4 to 6 Years
Apply by - Mar 31, 2023

Apply via the following link and share the opportunity with your friends - https://practice.geeksforgeeks.org/jobs/careers360-python-dev?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=pythondev

πŸ‘‰Visit our jobs portal 'Get Hired With GeeksforGeeks' for more such job opportunities - https://practice.geeksforgeeks.org/jobs

πŸ‘‰Also, do not miss the chance to get endless opportunities at Jobs Fair 2023 - https://practice.geeksforgeeks.org/jobs?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=jobfair2023
πŸ‘2
Problem Of The Day
"Number of Good Components"

Solve the problem to win points

Given an undirected graph with V vertices(numbered from 1 to V) and E edges. Find the number of good components in the graph.

A component of the graph is good if and only if the component is a fully connected component.

Note: A fully connected component is a subgraph of a given graph such that there's an edge between every pair of vertices in a component, the given graph can be a disconnected graph. Consider the adjacency list from index 1.

Example 1:
Input:

Output: 1
Explanation: We can see that there is only one
component in the graph and in this component
there is a edge between any two vertces.

Example 2:
Input:

Output: 2
Explanation: We can see that there are 3 components
in the graph. For 1-2-7 there is no edge between
1 to 7, so it is not a fully connected component.
Rest 2 are individually fully connected component.

Your Task:
You don't need to read input or print anything. Your task is to complete the function findNumberOfGoodComponent() which takes an integer V and an adjacency list adj as input parameters and returns an integer denoting the number of good components.

Expected Time Complexity: O(V+E)
Expected Auxiliary Space: O(depth of the graph)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1a4b617b70f0142a5c2b454e6fbe1b9a69ce7861/1

Powered by hirist.com
πŸ‘2
Must Learn!πŸ’‘
A network security key is a set of characters that authorize you to access a network. This key gives a secure connection between the serving network and the requesting client.

In other words, thr security key is another name for the Wi-Fi password. So, how will you find it?

This article talks about Network Security Key and the ways to find it in detail. Give it a read.

Link- https://www.geeksforgeeks.org/what-is-network-security-key-how-to-find-it/
πŸ‘2
Problem Of The Day
"Reverse both parts"

Solve the problem to win points

Given a linked list and a number k. You have to reverse first part of linked list with k nodes and the second part with n-k nodes.

Example 1:
Input: 1 -> 2 -> 3 -> 4 -> 5
k = 2
Output: 2 -> 1 -> 5 -> 4 -> 3
Explanation: As k = 2 , so the first part 2
nodes: 1 -> 2 and the second part with 3 nodes:
3 -> 4 -> 5. Now after reversing the first part:
2 -> 1 and the second part: 5 -> 4 -> 3.
So the output is: 2 -> 1 -> 5 -> 4 -> 3

Example 2:
Input: 1 -> 2 -> 4 -> 3
k = 3
Output: 4 -> 2 -> 1 -> 3
Explanation: As k = 3 , so the first part
3 nodes: 4 -> 2 -> 1 and the second part
with 1 nodes: 3. Now after reversing the
first part: 1 -> 2 -> 4 and the
second part: 3. So the output is: 1 -> 2 -> 4 -> 3

Your Task:
You don't need to read input or print anything. Your task is to complete the function reverse() which takes head node of the linked list and a integer k as input parameters and returns head node of the linked list after reversing both parts.


Constraints:
1 <= N <= 105
1 <= k < N

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/bae68b4d6a2a77fb6bd459cf7447240919ebfbf5/1

Powered by hirist.com
Must Learn!πŸ’‘
Many emails are lost in the receiver’s mailbox. Some are ignored or deleted, and some are responded to with a curt β€œunsubscribe.”

So, how can email campaigns achieve the best results?.

This article talks about email marketing trend that will on point, in detail. Give it a read.

Link- https://www.geeksforgeeks.org/top-10-email-marketing-trends/
πŸ‘1
Problem Of The Day
"Optimal Array"

Solve the problem to win points

You are given a sorted array a of length n. For each i(0<=i<=n-1), you have to make all the elements of the array from index 0 till i equal, using minimum number of operations. In one operation you either increase or decrease the array element by 1.

You have to return a list which contains the minimum number of operations for each i, to accomplish the above task.

Note:
1. 0-based indexing.
2. For each index, you need to consider the same array which was given to you at the start.

Example 1:
Input:
N=4
A={1,6,9,12}

Output:
0 5 8 14

Explanation:
For i=0, We do not need to perform any
operation, our array will be {1}->{1}.
And minimum number of operations
will be 0.

For i=1, We can choose to convert all
the elements from 0<=j<=i to 4, our
array will become {1,6}->{4,4}. And
minimum number of operations will be
|1-4|+|6-4|=5.

For i=2, We can choose to convert all
the elements from 0<=j<=i to 6, our
array will become {1,6,9}->{6,6,6} and
the minimum number of operations will
be |1-6|+|6-6|+|9-6|=8.

Similarly, for i=3, we can choose to
convert all the elements to 8,
{1,6,9,12}->{8,8,8,8}, and the
minimum number of operations will be 14.

Example 2:
Input:
N=7
A={1,1,1,7,7,10,19}

Output:
0 0 0 6 12 21 33

Explanation:
Possible operations could be:
{1}->{1}
{1,1}->{1,1}
{1,1,1}->{1,1,1}
{1,1,1,7}->{1,1,1,1}
{1,1,1,7,7}->{1,1,1,1,1}
{1,1,1,7,7,10}->{5,5,5,5,5,5}
{1,1,1,7,7,10,19}->{7,7,7,7,7,7,7}

Your Task:
You don't need to read input or print anything. Your task is to complete the function optimalArray() which takes N(length of array) and an array A as input and returns an array of size N with optimal answer for each index i.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/d4aeef538e6dd3280dda5f8ed7964727fdc7075f/1

Powered by hirist.com
Must Learn!πŸ’‘
Building projects is one of the best ways to learn C++. It provides valuable practical experience that enables us to make use of the concepts we learned to make something productive.

While building projects, we get to learn how to use different tools and solve different problems enhancing our ability to write code and problem-solving skills. It is also a great way to showcase one’s skills to a potential employer or client.

This article contains the 50 most popular and useful C++ project ideas for beginners, intermediate, and experts. Give it a read.

Link- https://www.geeksforgeeks.org/top-50-cpp-project-ideas-for-beginners-advanced/?utm_sour[…]_medium=marketingteam_gfgmain&utm_campaign=cppprojectideas
πŸ‘2πŸ”₯1
Problem Of The Day
"Update Queries"

Solve the problem to win points

You are given an array of n elements, initially all a[i] = 0. Q queries need to be performed. Each query contains three integers l, r, and x and you need to change all a[i] to (a[i] | x) for all l ≀ i ≀ r.

Return the array after executing Q queries.

Example 1:
Input:
N=3, Q=2
U=[[1, 3, 1],
[1, 3, 2]]

Output:
a[]={3,3,3}

Explanation:
Initially, all elements of the array are 0. After execution of the
first query, all elements become 1 and after execution of the
second query all elements become 3.

Example 2:
Input:
N=3, Q=2
U=[[1, 2, 1],
[3, 3, 2]]

Output:
a[]={1,1,2}

Explanantion:
[0,0,0] => [1,1,0] => [1,1,2]


Your Task:
You don't need to read input or print anything. Your task is to complete the function updateQuery() which takes the integer N,Q, and U a QX3 matrix containing the Q queries where U[i][0] is li, U[i][1] is ri andU[i][2] is xi.and it returns the final array a.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/a6528c893d4ab645ec6e0690c7982748385099c8/1

Powered by hirist.com
πŸ‘4
Must Learn!πŸ’‘
A full stack developer is a person who is an expert in designing, building, maintaining, and updating both the front end and back end of a website or a web application.

So, what are the requirements one has to fulfill in order to become a full stack developer?

This article talks about the role of full stack developers in detail. Give it a read.

Link- https://www.geeksforgeeks.org/requirements-to-become-a-full-stack-developer/?utm_source[…]dium=marketingteam_gfgmain&utm_campaign=fullstackdeveloper
πŸ‘1😁1
Problem Of The Day
"Walls Coloring II"

Solve the problem to win points

There is a row of N walls in Geeksland. The king of Geeksland ordered Alexa to color all the walls on the occasion of New Year. Alexa can color each wall with one of the K colors. The cost associated with coloring each wall with a particular color is represented by a 2D costs array of size N * K. For example, costs[0][0] is the cost of coloring wall 0 with color 0; costs[1][2] is the cost of coloring wall 1 with color 2, and so on... Find the minimum cost to color all the walls such that no two adjacent walls have the same color.

Note: If you are not able to paint all the walls, then you should return -1.

Example 1:
Input:
N = 4, K = 3
costs[][] = {{1, 5, 7},
{5, 8, 4},
{3, 2, 9},
{1, 2, 4}}

Output:
8
Explanation:
Paint wall 0 with color 0. Cost = 1
Paint wall 1 with color 2. Cost = 4
Paint wall 2 with color 1. Cost = 2
Paint wall 3 with color 0. Cost = 1
Total Cost = 1 + 4 + 2 + 1 = 8

Example 2:
Input:
N = 5, K = 1
costs[][] = {{5},
{4},
{9},
{2},
{1}}
Output:
-1
Explanation:
It is not possible to color all the walls under the given conditions.


Your Task:
Your task is to complete the function minCost() which takes a 2D integer matrix costs as the only argument and returns an integer, representing the minimum cost to paint all the walls. If you are not able to paint all the walls, then you should return -1

Expected Time Complexity: O(N*K)
Expected Space Complexity: O(N*K)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/9dacc32ad062be6e2ba8f6c41aad0b2b2376397d/1

Powered by hirist.com
πŸ‘1
This media is not supported in your browser
VIEW IN TELEGRAM
Must Learn!πŸ’‘
JavaScript is by far of the most popular languages when it comes to web development, powering most websites and web applications.

There are ways to use Java in an enhanced manner and every Java Developer should be aware of them.

This article deals with the forementioned topic in detail. Give it a read.

Link- https://www.geeksforgeeks.org/8-tips-and-tricks-for-javascript-developers/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=javascriptdevelopers
Looking for a switch?

Well, we are here with endless opportunities at 'GeeksforGeeks Jobs Fair 2023'.πŸ˜ƒπŸ€Œ

This is the right move to give a boost to your career.πŸ’«

Start applying now - https://practice.geeksforgeeks.org/jobs?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=jobfair2023
πŸ”₯2
Problem Of The Day
"Cutting Rectangles"

Solve the problem to win points

Given a rectangle of dimensions L x B find the minimum number (N) of identical squares of maximum side that can be cut out from that rectangle so that no residue remains in the rectangle. Also find the dimension K of that square.

Example 1:
Input: L = 2, B = 4
Output: N = 2, K = 2
Explaination: 2 squares of 2x2 dimension.

Example 2:
Input: L = 6, B = 3
Output: N = 2, K = 3
Explaintion: 2 squares of 3x3 dimension.

Your Task:
You do not need to read input or print anything. Your task is to complete the function minimumSquares() which takes L and B as input parameters and returns a list of 2 integers containing the values of N and K respectively.

Expected Time Complexity: O(log min(L, B))
Expected Auxiliary Space: O(1)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/a7a4da81b20f4a05bbd93f5786fcf7478298f4f5/1

Powered by hirist.com
Must Learn!πŸ’‘
What is it that never goes out of trend/trolls/twists? The answer is Cryptocurrency. Cryptocurrency is a form of digital money.

In March 2021 when Bitcoin was at its all-time high, almost all the investors thought they’d get filthy rich. Cut to July 2021, Bitcoin prices dropped by 50% and it soared through the year and most of 2022, recording its lowest at $29,000 in May 2022.

So, how will you evaluate the benefits and risks of Cryptocurrency?

This article deals with the mentioned issue. Give it a read.

Link- https://www.geeksforgeeks.org/cryptocurrency-good-or-bad-investment/?utm_source=telegra[…]m_medium=marketingteam_gfgmain&utm_campaign=cryptocurrency
Problem Of The Day
"Best Node"

Solve the problem to win points

You are given a tree rooted at node 1. The tree is given in form of an array P where Pi denotes the parent of node i, Also P1 = -1, as 1 is the root node. Every node i has a value Ai associated with it. At first, you have to choose any node to start with, after that from a node you can go to any of its child nodes. You've to keep moving to a child node until you reach a leaf node. Every time you get to a new node, you write its value. Let us assume that the integer sequence in your path is B.

Let us define a function f over B, which is defined as follows:
f(B) = B1 - B2 + B3 - B4 + B5.... + (-1)(k-1)Bk.
You have to find the maximum possible value of f(B).

Example 1:
Input:
N = 3,
A = { 1, 2, 3}
P = {-1, 1, 1}
Output:
3
Explanation:
The resulting tree is:
1(1)
/ \
2(2) 3(3)
If we choose our starting node as 3, then the
resulting sequence will be B = { 3 },
which will give the maximum possible value.

Example 2:
Input:
N = 3,
A = { 3, 1, 2}
P = {-1, 1, 2}
Output:
4
Explanation:
The resulting tree is:
1(3)
|
2(1)
|
3(2)
If we choose our starting node as 1, then the
resulting sequence will be B = { 3 , 1 , 2 }.
The value which we'll get is, 3-1+2 = 4, which
is the maximum possible value.
Your Task:
The task is to complete the function bestNode() which takes an integer N and two integer arrays A, P as input parameters and returns the maximum possible value possible.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/a3493283697b7b69573a840f371a55ccd9332bb0/1

Powered by hirist.com
πŸ‘1
Must Learn!πŸ’‘
The method of producing animated images and visual effects with computer software is referred to as software animation.

Several industries, including film and television, video games, advertising, and web design, might benefit from software animation.

However, it is confusing for beginners to decide about which software to use for the animation. This article will help you sort it out. Give it a read.

Link- https://www.geeksforgeeks.org/best-animation-softwares-for-beginers/?utm_source=telegra[…]m=marketingteam_gfgmain&utm_campaign=bestanimationsoftware
πŸ‘1
🚨Job Alert🚨
Geninvo is hiring for Full Stack Developer (Java).

Location - Mohali (Chandigarh)
Experience - 2 - 8 Years
Apply by - Mar 15, 2023

Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/Geninvo-Fullstack-developer

πŸ“’: Also, do not miss the chance to get endless opportunities at Jobs Fair 2023 - https://practice.geeksforgeeks.org/jobs?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=jobfair2023
πŸ‘2
Problem Of The Day
"Avoid Explosion"

Solve the problem to win points

Geek is a chemical scientist who is performing an experiment to find an antidote to a poison. The experiment involves mixing some solutions in a flask. Based on the theoretical research Geek has done, he came up with an n * 2 array 'mix', where mix[i] = {X, Y} denotes solutions X and Y that needs to be mixed.

Also, from his past experience, it has been known that mixing some solutions leads to an explosion and thereby completely ruining the experiment. The explosive solutions are also provided as a m * 2 array 'danger' where danger[i] = {P, Q} denotes that if somehow solutions P and Q get into the same flask it will result in an explosion.

Help the Geek by returning an array 'answer' of size n, where answer[i] = "Yes" if it is safe to mix solutions in 'mix[i]' or else answer[i] = "No".

Note: Geek should follow the order of mixing of solutions as it is in 'mix' otherwise the antidote will be ineffective. Also, Geek will not mix the solutions in 'mix[i]' once he gets to know that mixing them will result in an explosion. Mixing a solution will effect the other solutions which will appear after it.

Example 1:
Input:
n = 5, m = 2
mix = {{1, 2}, {2, 3}, {4, 5}, {3, 5}, {2, 4}}
danger = {{1, 3}, {4, 2}}

Output:
answer = {"Yes", "No", "Yes", "Yes", "No"}

Explanation:
Mixing the first solution(1 and 2) of 'mix' do not result in any kind of explosion hence answer[0] is "Yes", while mixing(2nd solution) 2 and 3 is not allowed because it will result in an explosion as 1 and 3 would be in same solution hence we have returned "No" as the answer for 2nd solution. Mixing the third solution(4 and 5) and 4th solution(3 and 5) of 'mix' do not result in any kind of explosion hence answer[2] and answer[3] is "Yes". While mixing 2 and 4 is not allowed because it will result in an explosion hence we have returned "No" as the answer for it.

Example 2:
Input:
n = 3, m = 2
mix = {{1, 2}, {2, 3}, {1, 3}}
danger = {{1, 2}, {1, 3}}

Output:
answer = {"No", "Yes", "No"}

Explanation:
Mixing solutions 1 and 2 is dangerous hence
answer[0] = "No", but solutions 2 and 3 can
be mixed without any problem therefore answer[1]
= "Yes". Again, mixing solutions 1 and 3 is
dangerous due to which answer[2] = "No".


Your Task:
You don't need to read input or print anything. Complete the function avoidExplosion() which takes the mix array, its size, danger array, and its size as input parameters and returns the result array or list.

Expected Time Complexity: O(n*m*log(n))
Expected Space Complexity: O(n)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/d3fd6eb758469ab11e1a812220740d1f9819be70/1

Powered by hirist.com
πŸ‘1