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
Must Learn!πŸ’‘
Machine learning has made significant strides in recent years, and one remarkable application is ChatGPT, an advanced language model developed by OpenAI.

ChatGPT can engage in natural language conversations, making it a versatile tool for various applications.

In this article, we will explore the top 20 ChatGPT prompts for machine learning. Give it a read.

Link- https://www.geeksforgeeks.org/top-chatgpt-prompts-for-machine-learning/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=chatgptpromptsmachinelearning
🚨Job Alert🚨
MOON Technolabs is hiring for Node JS Developer.

Location - Ahmedabad
Experience - 3 - 7.5 Years
Apply by - Jul 12, 2023

Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/moon-srnodejsdeveloper?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=nodejsdeveloper
Problem Of The Day
"Maximum Diamonds"

Solve the problem to win points

There are N bags with diamonds in them. The i'th of these bags contains A[i] diamonds. If you drop a bag with A[i] diamonds, it changes to A[i]/2 diamonds and you gain A[i] diamonds. Dropping a bag takes 1 minute. Find the maximum number of diamonds that you can take if you are given K minutes.

Example 1:

Input:
N = 5, K = 3
A[] = {2, 1, 7, 4, 2}
Output:
14
Explanation:
The state of bags is:
2 1 7 4 2
You take all diamonds from Third bag (7).
The state of bags becomes: 2 1 3 4 2
Take all diamonds from Fourth bag (4).
The state of bags becomes: 2 1 3 2 2
Take all diamonds from Third bag (3).
The state of bags becomes: 2 1 1 2 2
Hence, number of Diamonds = 7+4+3 = 14.

Example 2:

Input:
N = 3, K = 2
A[] = {7, 1, 2}
Output:
10
Explanation:
You take all diamonds from First bag (7).
The state of bags becomes: 3 1 2
Take all diamonds from again First bag (3).
The state of bags becomes: 1 1 2
You can take a maximum of 10 diamonds.

Your Task:
You don't need to read input or print anything. Your task is to complete the function maxDiamonds() which takes 2 Integers N, and K and an integer and an array A[] of N integers as input and returns the maximum number of diamonds you can take in K minutes.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/chinky-and-diamonds3340/1

Powered by hirist.com
πŸ‘3
Must Learn!πŸ’‘
Machine learning has made significant strides in recent years, and one remarkable application is ChatGPT, an advanced language model developed by OpenAI.

ChatGPT can engage in natural language conversations, making it a versatile tool for various applications.

In this article, we will explore the top 20 ChatGPT prompts for machine learning. Give it a read.

Link- https://www.geeksforgeeks.org/python-one-liners-that-developers-must-know/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=pythononeliners
πŸ‘2
Problem Of The Day
"Longest Palindrome in a String"

Solve the problem to win points

Given a string S, find the longest palindromic substring in S. Substring of string S: S[ i . . . . j ] where 0 ≀ i ≀ j < len(S). Palindrome string: A string that reads the same backward. More formally, S is a palindrome if reverse(S) = S. In case of conflict, return the substring which occurs first ( with the least starting index).

Example 1:
Input:
S = "aaaabbaa"
Output: aabbaa
Explanation: The longest Palindromic
substring is "aabbaa".

Example 2:
Input:
S = "abc"
Output: a
Explanation: "a", "b" and "c" are the
longest palindromes with same length.
The result is the one with the least
starting index.

Your Task:
You don't need to read input or print anything. Your task is to complete the function longestPalin() which takes the string S as input and returns the longest palindromic substring of S.

Expected Time Complexity: O(|S|2).
Expected Auxiliary Space: O(1).

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1

Powered by hirist.com
πŸ‘1
Must Learn!πŸ’‘
In today’s time, python is the most popular language among development professionals which was developed by Guido Van Rossum in 1991.

Python is an open-source and high-level programming language that supports much functionality that makes it so popular among developers.

In this article, we will read about the various career scopes of Python developers, jobs and salary trends, skills needed for a Python developer, and the various advantages of Python language over other programming languages.

Link- https://www.geeksforgeeks.org/scope-of-python-in-india/
Problem Of The Day
"Min Time"

Solve the problem to win points

Given an array locations[] of size n where locations[i] represents the location of the ith fruit on the x-axis and also given an array types[] where types[i] is an integer which represents the type of the ith fruit. You are initially at coordinate 0 and you have to collect all the fruits and then return back to coordinate 0 again. To move 1 unit on the x-axis requires 1 second of time. The only condition is that you have to collect the fruits in a non-decreasing order of their types[i] (for example if ith fruit has type[i]=1 and jth fruit has type[j]=2 then ith fruit has to be picked before jth fruit). Find minimum time to collect all fruits in the non-decreasing order of their types and return back to coordinate 0.

Note: You can assume it takes no time to pick up fruit and the location of a fruit can be negative also.

Example 1:
Input:
n=4
locations={1,3,5,7}
types={1,2,3,1}
Output:
18
Explanation:
You start at x=0 and move to x=7 and
in the way pick fruits of type 1 at x=1
and x=7 and it took total 7 seconds to
move from 0->7 now you move to x=3
in 4 seconds and than to x=5 in 2 seconds
and than return back to x=0 in 5 seconds.
So overall it took 18 seconds(7+4+2+5).

Example 2:
Input:
n=4
locations={-4,-3,1,-8}
types={4,2,4,5}
Output:
24
Explanation:
The optimal way is to way go to x=-3
in starting than 1 and follow path
like this (1)->(-4)->(-8)->(0) and
total time it takes is 24 .

Your Task:
You don't need to read input or print anything. Your task is to complete the function minTime() which takes an integer n, integer array locations and types and you have to return minimum time to collect all fruits.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/95bb244da24edd6214086ff934886ccda6ed9da8/1
Must Learn!πŸ’‘
Once the designs are ready, to run a usability test heuristics principles come into the picture, using which we carry out the heuristic evaluation.

Though usability is a vast field and includes a lot more than just heuristic evaluation, it is an essential practice.

In this article, we would be looking into some very important heuristics to evaluate whether the design you have created is usable or not.

Link- https://www.geeksforgeeks.org/top-heuristic-principles-with-examples-for-interactive-designs/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=topheuristicprinciples
Problem Of The Day
"Queue Operations"

Solve the problem to win points

Given N integers, the task is to insert those elements in the queue. Also, given M integers, the task is to find the frequency of each number in the Queue.
Note:

insert() will be called N times by main().
findFrequency() will be called M times by main();
Where k is each element passing through respective function calls.

Example 1:

Input:
N = 8
1 2 3 4 5 2 3 1
M = 5
1 3 2 9 10
Output:
2
2
2
-1
-1
Explanation:
After inserting 1, 2, 3, 4, 5, 2, 3 and 1 into the queue, frequency of 1 is 2, 3 is 2 and 2 is 2. Since 9 and 10 are not there in the queue we output -1 for them.

Example 2:

Input:
N = 6
1 2 1 1 1 4
M = 4
1 5 4 3
Output:
4
-1
1
-1
Explanation:
After inserting 1, 2, 1, 1, 1 and 4 into the queue, frequency of 1 is 4 and that of 4 is 1. Since 5 and 3 are not there in the queue we output -1 for them.

Your Task:
Your task is to complete the functions insert() and findFrequency() which inserts the element into the queue and find the count of occurences of element in the queue respectively.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/queue-operations/1
Join today and get introduced to our newly launched: DSA To Development Program!
.
.
Set Reminder now: www.youtube.com/live/eaoMNmJH6no?feature=share
❀3πŸ‘3
πŸ‘‰Apply for DSA To Development - A Complete Coding Guide: https://lnkd.in/dAxuguwF

Apply now and fill up the application form with your details. It may take 24-48 Hours for your application status to be updated. All the best!
πŸ‘2
Problem Of The Day
"Ticket Counter"

Solve the problem to win points

N people from 1 to N are standing in the queue at a movie ticket counter. It is a weird counter, as it distributes tickets to the first K people and then the last K people and again first K people and so on, once a person gets a ticket moves out of the queue. The task is to find the last person to get the ticket.

Example 1:
Input:
N = 9
K = 3
Output:
6
Explanation:
Starting queue will like {1, 2, 3, 4, 5, 6, 7, 8, 9}. After the first distribution queue will look like {4, 5, 6, 7, 8, 9}. And after the second distribution queue will look like {4, 5, 6}. The last person to get the ticket will be 6.

Example 2:
Input:
N = 5
K = 1
Output:
3
Explanation:
Queue start as {1, 2, 3, 4, 5} -> {2, 3, 4, 5} -> {2, 3, 4} -> {3, 4} -> {3}
Last person to get ticket will be 3.

Your Task:
You don't need to read input or print anything. Your task is to complete the function distributeTicket() which takes N and K as inputs and returns the last person to get the ticket.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/ticket-counter-2731/1
πŸ‘2
Happy Father's Day ❀️
❀32πŸ‘4
Problem Of The Day
"Rearrange an array with O(1) extra space"

Solve the problem to win points

Given an array arr[] of size N where every element is in the range from 0 to n-1. Rearrange the given array so that the transformed array arrT[i] becomes arr[arr[i]].

NOTE: arr and arrT are both same variables, representing the array before and after transformation respectively.

Example 1:
Input:
N = 2
arr[] = {1,0}
Output: 0 1
Explanation:
arr[arr[0]] = arr[1] = 0.
arr[arr[1]] = arr[0] = 1.

Example 2:
Input:
N = 5
arr[] = {4,0,2,1,3}
Output: 3 4 2 0 1
Explanation:
arr[arr[0]] = arr[4] = 3.
arr[arr[1]] = arr[0] = 4.
and so on.

Your Task:
You don't need to read input or print anything. The task is to complete the function arrange() which takes arr and N as input parameters and rearranges the elements in the array in-place.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/rearrange-an-array-with-o1-extra-space3142/1
Must Learn!πŸ’‘
Each software can be used for a specific domain of work like Coding, Painting, Writing, etc. That is the reason, many of us installed software for computers for any specific reason.

Some software needs subscription plans to use it & some of them are completely free. Obviously, users are tilted toward the use of free software on PC.

This article will enlighten some of the important free software for Windows that must be installed to get an extra edge in that domain.

Link- https://www.geeksforgeeks.org/best-free-software-for-windows/
πŸ‘3
Hey freshers! We are back for you. πŸ˜ƒπŸŽŠ

These opportunities are exclusively for you. So, no more tension of placement because we got your back!πŸ•Ί

Don't wait! Register and be eligible for your own hiring challenge and grab the best opportunities.πŸ‘©β€πŸ’»

Register here: https://practice.geeksforgeeks.org/contest/megajob-a-thon-hiring-challenge-freshers?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
Problem Of The Day
"Matchsticks game"

Solve the problem to win points

Two friends, A and B, are playing the game of matchsticks. In this game, a group of N matchsticks is placed on the table. The players can pick any number of matchsticks from 1 to 4 (both inclusive) during their chance. The player who takes the last match stick wins the game. If A starts first, how many matchsticks should he pick on his 1st turn such that he is guaranteed to win the game or determine if it's impossible for him to win. Return -1 if it's impossible for A to win the game, else return the number of matchsticks should he pick on his 1st turn such that he is guaranteed to win.
Note : Consider both A and B play the game optimally.

Example 1:
Input:
N = 48
Output:
3
Explanation:
Player A is guaranteed a win if he
picks 3 matchsticks first.

Example 2:
Input:
N = 15
Output:
-1
Explanation:
Player A is guaranteed a loss no matter
how many matches he picks at first.

Your Task:
You don't need to read input or print anything. Your task is to complete the function matchGame() which takes an Integer N as input and returns the answer.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/-matchsticks-game4906/1
πŸ‘1
Must Learn!πŸ’‘
Python is popular among developers for being a convenient language that is easy to use due to its syntax and flow.

There are much more reasons why Python is a trending programming language. But what is the scope of Python in India? This article deals with this question in detail. Give it a read.

Link- https://www.geeksforgeeks.org/scope-of-python-in-india/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=scopeofpythoninindia
Problem Of The Day
"Reverse Coding"

Solve the problem to win points

You will be given an integer n, your task is to return the sum of all natural number less than or equal to n.

As the answer could be very large, return answer modulo 109+7.

Example 1:

Input:
n = 6
Output:
21
Explanation:
1+2+3+4+5+6 = 21

Example 2:

Input:
n = 4
Output:
10
Explanation:
1+2+3+4 = 10

Your Task:
You don't need to read input or print anything. Your task is to complete the function sumOfNaturals() which takes a single integer n as input and returns sum of all numbers x upto n, i.e., 1 <= x <= n.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/reverse-coding2452/1
πŸ‘2
Must Learn!πŸ’‘
While there are various web hosting options available, GitHub has emerged as a popular choice for hosting websites due to its simplicity, versatility, and seamless integration with version control systems.

In this comprehensive guide, we will walk you through the process of hosting a website on GitHub for free, even if you have little to no prior experience with web development or hosting. Give it a read.

Link- https://www.geeksforgeeks.org/how-to-host-a-website-on-github-for-free/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github