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 روز
آرشیو پست ها
================================================
Hope you guys have solved Question 12.
Question 12:
Zig-zag conversion: Given a string, and number of rows, write the string in zigzag pattern.
Write your thoughts in the comment section of the link below:
https://www.prodevelopertutorial.com/given-a-string-and-number-of-rows-write-the-string-in-zigzag-pattern/
Difficulty: Medium
Company: paypal
================================================
Todays Question 13:
Longest Palindromic Substring
Given a string, find the longest palindromic string in that array.
A palindromic string will give the same string when read reverse.
Example:
“aba” reverse is “aba” hence is a palindromic string.
Input: ashdkabajjseiw
Output: aba
Please try to solve in O(n^2).
Difficulty: Medium
Company: Microsoft, groupon, accolite
Link for todays question:
https://www.prodevelopertutorial.com/longest-palindromic-substring-with-detailed-explanation-and-solution-in-c/
================================================
Question 12:
Zig-zag conversion: Given a string, and number of rows, write the string in zigzag pattern.
Write your thoughts in the comment section of the link below:
https://www.prodevelopertutorial.com/given-a-string-and-number-of-rows-write-the-string-in-zigzag-pattern/
Difficulty: Medium
Company: paypal
Quick Update:
Till now I was posting questions in random order of difficulty. But from now on, from monday to saturday I shall be posting questions of difficulty easy to medium [mostly medium]. On sunday I shall be posting a hard question. These hard question will take lot of time to complete. And sunday most of them are free try to understand and come up with a solution. Any feedback please let me know.
Public poll:
I am planning to create a discussion forum in the website so that you guys can hangout there, discuss the problems and solutions, request for tutorials, and share your interview experience. I would like to know if it would be helpful for you guys. Please let me know personally, so that, I shall work on it at the earliest.
Hope you guys have solved question 8 and question 9. Click on the below link to know the solution. Please write your solution in the comment section of the post.
Question 10: Given an array, find all the repeated elements.
https://www.prodevelopertutorial.com/given-an-array-find-all-the-repeated-elements-in-c-language/
Question 11: Given an integer value, convert it into roman number.
https://www.prodevelopertutorial.com/given-an-integer-value-convert-it-into-roman-number/
Let me know your thoughts in the comment section of the post below.
Question 10
=================
Given an array, find all the repeated elements.
Problem Description:
Given a positive integer array, find all the elements that have been repeated and display them.
Example:
Input:
{1, 3, 2, 7, 5, 1, 8, 3, 6, 10}
Output:
1, 3
Difficulty: Medium
Asked in company: Amazon, paytm
Question 11:
=================
Given an integer value, convert it into roman number.
Problem Explanation:
Roman numbers are represented by below characters:
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
IV 4
IX 9
XL 40
XC 100
CD 400
CM 900
Example:
Input: 3
Output: "III"
Input: 58
Output: "LVIII"
Difficulty: Medium
Company: Microsoft, facebook, amazon
Hope you guys have solved question 8 and question 9. Click on the below link to know the solution. Please write your solution in the comment section of the post.
Question 8: Given an unsorted array, and a key. Find 2 elements such that the difference between the elements is equal to the key.
Solution: https://www.prodevelopertutorial.com/given-an-unsorted-array-and-a-key-find-2-elements-such-that-the-difference-between-the-elements-is-equal-to-the-key/
Question 9: Given an unsorted integer array, find the smallest missing positive integer.
Solution: https://www.prodevelopertutorial.com/given-an-unsorted-integer-array-find-the-smallest-missing-positive-integer/
Question 8 :
================
Given an unsorted array, and a key. Find 2 elements such that the difference between the elements is equal to the key.
Example:
{4, 2, 5, 8, 21, 34, 10} key = 24
Output:
Pair found (34, 10)
Difficulty: Easy
https://www.prodevelopertutorial.com/given-an-unsorted-array-and-a-key-find-2-elements-such-that-the-difference-between-the-elements-is-equal-to-the-key/
As question 8 is easy solve below question 9 also today.
Question 9 :
===================
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
Input: [ 2, 3, -1, -2]
Output: 1
Example 2:
Input: [5, 6, 7, 8, 9]
Output: 1
Your algorithm should run in O(n) time and uses constant space.
Integer starts from 1. Hence consider the smallest +ve integer is 1.
https://www.prodevelopertutorial.com/given-an-unsorted-integer-array-find-the-smallest-missing-positive-integer/
Difficulty: hard
Hope you guys have solved day 7 question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/given-an-unsorted-array-find-the-list-difference-between-the-element-pairs-display-all-the-pairs-present/
Day 7 Question:
Given an unsorted array, find the list difference between the element pairs. Display all the pairs present.
Problem Statement:
Given an unsorted array, list all the pairs with a least difference.
Example:
Input:
{5, 4, 3, 2, 1}
Output:
{1, 2}, {2, 3}, {3, 4}, {4, 5}.
Difficulty: Easy
Postyour solution in the comment section of the below link:
https://www.prodevelopertutorial.com/given-an-unsorted-array-find-the-list-difference-between-the-element-pairs-display-all-the-pairs-present/
Pro Tip: If you are not able to solve the problem, when I give you the solution, try to compile and run the program. Try it with different inputs and understand the program output.
Hope you guys have solved day 6 question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/given-an-unsorted-array-find-the-minimum-difference-between-2-elements/
Day 6 Question:
Given an unsorted array, find the minimum difference between 2 elements.
Problem Explanation:
Given an unsorted array, the output should be the minimum difference between the elements and the elements itself.
Example:
{6, 10, 5, 42, 43, 1, 2}
output:
The minimum difference between is 1 the elements are 1 and 2.
Difficulty: Easy
Asked in company: Amazon
Note: The solutions will be provided in C or C++. I encourage you to please try out in other languages and write the solution in the comment section of the link below.
https://www.prodevelopertutorial.com/given-an-unsorted-array-find-the-minimum-difference-between-2-elements/
Hope you guys have solved todays question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/given-an-array-the-difference-between-the-elements-is-one-find-if-the-key-element-is-present-or-not/
I appreciate that some of you guys have written the logic in comment section of the post. Keep up the good work. It will definately improve your programming skills.
Day 5 Question:
Given an array, the difference between the elements is one, find if the “key” element is present or not.
Example:
Array:
{5, 6, 7, 6, 5, 4, 3, 4, 5, 6}
Key:
4
Output:
The element 4 is found at the index 6.
Difficulty: Easy
Note: This answer can be solved by iterating throught all the array elements as a brute force method. But that answer is not acceptable. Please solve by different logic.
Post your answers in the comment section of the link below. Night I shall provide you with answer.
https://www.prodevelopertutorial.com/given-an-array-the-difference-between-the-elements-is-one-find-if-the-key-element-is-present-or-not/
Hope you guys have solved todays question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/sort-an-array-of-0s-1s-and-2s-in-c/
Day 4 Question:
Sort an array of 0s, 1s and 2s in C
Problem Description:
Given an array of elements consisting of 0, 1, 2. Sort the array.
Example:
{1, 2, 0, 0, 1, 2, 1}
Output:
{0, 0, 1, 1, 1, 2, 2}
Difficulty: Easy
Asked in company: Amazon
Hope you guys have solved todays question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/count-the-number-of-ways-a-baby-can-reach-the-nth-stair-taking-1-or-2-steps-at-a-time-in-c-language/
Day 3 Question:
Count the number of ways a baby can reach the n’th stare taking 1 or 2 steps at a time in C language.
Problem Description:
A baby wants to climb the stairs. It can take single step at a time or take 2 steps at a time. Or it can take combination of 1 and 2 steps at a time.
Given that there are N stairs, find the number of ways the baby can reach the top of the stairs.
Difficulty: Easy
Asked in company: Amazon, Intel
Hope you guys have solved todays question. Click on the below link to know the solution. Please write your solution in the comment section of the post.
https://www.prodevelopertutorial.com/given-two-non-empty-linked-list-with-non-negative-numbers-and-numbers-are-stored-in-reverse-order-having-single-digit-add-the-two-list-and-return-the-result-as-a-linked-list/
Day 2 Question:
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Example
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.
Difficulty: Medium
Asked in company: Amazon
