Competitive Programming
الذهاب إلى القناة على Telegram
Solving competitive Programming Questions one day at a time. Group link: https://t.me/daily1interviewprogram Please forward it to your friends
إظهار المزيدلم يتم تحديد البلدالفئة غير محددة
4 553
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
Day 24 Question:
Given a linked list, swap every two adjacent nodes and return its head.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
Difficulty: Medium
Please write your solution in comment section of the post below:
https://www.prodevelopertutorial.com/swap-nodes-in-pairs/
Programming quote for the day:
“ Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet. ” - Michael A. Jackson
Hope you have solved Day 22 question.
Day 22 Question:
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Solution:
https://www.prodevelopertutorial.com/given-n-pairs-of-parentheses-write-a-function-to-generate-all-combinations-of-well-formed-parentheses/
Please comment with your answers in the comment section of the above post.
Day 23 Question:
Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
Difficulty: Easy
Programming quote for the day:
“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ” - Edsger Dijkstra
Day 22 Question:
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]
Difficulty: Medium
Motivational Quote for the day:
Without hard work and discipline it is difficult to be a top professional.
Hope you have solved todays question.
Day 21 Question:
Letter Combinations of a Phone Number
Solution:
https://www.prodevelopertutorial.com/letter-combinations-of-a-phone-number/
Please comment with your answers in the comment section of the above post.
Note: Day 20 answer shall be posted soon. Sorry for the delay.
Day 21 Question:
Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
Input: "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Difficulty: Medium to high
companies asked: flipkart
Motivational Quote for the day:
Perseverance is the hard work you do after you get tired of doing the hard work you already did.
Note: Solution to question 20 and 21 will be provided EOD.
Day 20 Question:
Remove Nth Node From End of List
Given a linked list, remove the n-th node from the end of list and return its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
Follow up:
Could you do this in one pass?
Difficulty: Medium
Motivational Quote for the day:
Success isn't always about greatness. It's about consistency. Consistent hard work leads to success. Greatness will come.
Hope you have solved todays question.
Day 19 Question:
Given an array n integers and an integer key, are there four elements a, b, c, and d in the array such that a + b + c + d = key? Find all unique quadruplets in the array which gives the sum of key.
Solution:
https://www.prodevelopertutorial.com/given-an-array-n-integers-and-an-integer-key-are-there-four-elements-a-b-c-and-d-in-the-array-such-that-a-b-c/
Please comment with your answers in the comment section of the above post.
Few of the kind appreciation that I have received from you guys. Suggestions and feedback are always welcome. Share the group to maximum students who are in need.
Day 19 Question:
Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Given array nums = [1, 0, -1, 0, -2, 2], and target = 0.
A solution set is:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]
Difficulty: Medium
Motivational Quote for the day:
Without hard work, nothing grows but weeds.
Hope you have solved todays question.
Day 18 Question:
Given an array of n integers and an integer “key”, find three integers in the array such that the sum is closest to key.
Solution:
https://www.prodevelopertutorial.com/given-an-array-of-n-integers-and-an-integer-key-find-three-integers-in-the-array-such-that-the-sum-is-closest-to-key/
Please comment with your answers in the comment section of the above post.
Day 18 Question:
Given an array of n integers and an integer “key”, find three integers in the array such that the sum is closest to key.
Input: [-1, 2, 1, -4]
Key = 1
Output:
The sum that is closest to the target is 2. (-1 + 2 + 1 = 2)
This problem is also known as three sum closest
You can write your answers in the commnent section of the link below:
https://www.prodevelopertutorial.com/given-an-array-of-n-integers-and-an-integer-key-find-three-integers-in-the-array-such-that-the-sum-is-closest-to-key/
Difficulty: Medium
Asked in Companies: Accolite Samsung CarWale
Motivational Quote for the day:
A dream doesn't become reality through magic; it takes sweat, determination and hard work.
Note:
Please spend atleast 1 hour to solve the questions. By solving 1 question a day, in a month you will be solving 30 questions and in a year 365 questions !!!
Hope you have solved todays question.
Day 17 Question:
Given an array, find 3 elements such that [a + b + c] = 0. Find all the 3 unique elements.
Solution:
https://www.prodevelopertutorial.com/given-an-array-find-3-elements-such-that-a-b-c-0-find-all-the-3-unique-elements/
Please comment with your answers in the comment section of the above post.
Note: Some of you have requested me to post difficult questions. But as you can see that there are many freshers joined in this group. For them to get comfortable I am posting medium difficulty question. After some days I shall start posting more difficult questions.
Day 17 Question:
Given an array, find 3 elements such that [a + b + c] = 0. Find all the 3 unique elements.
Input: = [-1, 0, 1, 2, -1, -4],
Output:
[
[-1, 0, 1],
[-1, -1, 2]
]
Solve it with the time complexity O(n^2).
Difficulty: Medium
Companies asked: Facebook Google
Motivational Quote for the day:
Success is no accident. It is hard work, perseverance, learning, studying, sacrifice and most of all, love of what you are doing or learning to do.
Note:
All the solutions are best viewed on laptop.
Hope you have solved todays question.
Question 16:
Given an array of non repeating numbers and a key, find all the unique combinations in that array, where the sum of those combination is equal to the key.
Solution:
https://www.prodevelopertutorial.com/given-an-array-of-non-repeating-numbers-and-a-key-find-all-the-unique-combinations-in-that-array-where-the-sum-of-those-combination-is-equal-to-the-key/
Please comment with your answers in the comment section of the above post.
Note: Form tomorrow, along with the question, I'll send a motivational quote. So that you feel inspired and solve the questions. Cheers :)
Any feedbacks are also welcome.
Day 16 Question:
Given an array of non repeating numbers and a key, find all the unique combinations in that array, where the sum of those combination is equal to the key.
Input:
Array = [2,3,6,7], key = 7,
Output:
[
[7],
[2,2,3]
]
Example 2:
Input: candidates = [2,3,5], target = 8,
A solution set is:
[
[2,2,2,2],
[2,3,3],
[3,5]
]
Try the solution with backtracking approach.
Difficulty: Medium
Microsoft Amazon Adobe
Hope you have solved todays question.
Please comment below with your answers:
Question 14:
Find the Container with Most Water explanation with diagram and solution in cpp language
Solution:
https://www.prodevelopertutorial.com/find-the-container-with-most-water-explanation-with-diagram-and-solution-in-cpp-language/
Day 15 Question:
Find the Container with Most Water
Problem description:
Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
[Additional explination is given in the post]
The solution should be time complexity of O (n) and space complexity O( 1 )
Input: [3, 1, 2, 4, 5]
Output: 12
Difficulty: Medium
Company: NA
Please write your answers in the comment section of the post below:
https://www.prodevelopertutorial.com/find-the-container-with-most-water-explanation-with-diagram-and-solution-in-cpp-language/
Hope you have solved todays Diffcult question.
Please comment below with your answers:
Question 13 solution:
Longest Palindromic Substring with detailed explanation and solution in C++.
https://www.prodevelopertutorial.com/longest-palindromic-substring-with-detailed-explanation-and-solution-in-c/
Question 14 solution:
Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’.
https://www.prodevelopertutorial.com/given-an-input-string-s-and-a-pattern-p-implement-regular-expression-matching-with-support-for-and/
Todays Question 14:
Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’.
note:
s could be empty and contains only lowercase letters a-z.
p could be empty and contains only lowercase letters a-z, and characters like . or *.
Example 1:
Input:
s = "aa"
p = "a*"
Output: true
Explanation: '*' means zero or more of the precedeng element, 'a'. Therefore, by repeating 'a' once, it becomes
Example 2:
Input:
s = "ab"
p = ".*"
Output: true
Explanation: ".*" means " zero or more (*) of any character (.)".
Please write the solution in below link:
https://www.prodevelopertutorial.com/given-an-input-string-s-and-a-pattern-p-implement-regular-expression-matching-with-support-for-and/
Difficulty: Hard
Company: Facebook, Microsoft
Note: The solution for Question 13 and 14 will be provided end of the day.
