Competitive programming questions
Open in Telegram
Solving competitive Programming Questions one day at a time. Group link: https://t.me/competitive_programming_question Please forward it to your friends
Show moreThe country is not specifiedThe category is not specified
6 861
Subscribers
No data24 hours
No data7 days
No data30 days
Posts Archive
Day 30 Question:
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1 = "123", num2 = "456"
Output: "56088"
Note:
The length of both num1 and num2 is < 110.
Both num1 and num2 contain only digits 0-9.
Both num1 and num2 do not contain any leading zero, except the number 0 itself.
You must not use any built-in BigInteger library or convert the inputs to integer directly.
Difficulty: Medium
Quote for the day:
The fruit of your own hard work is the sweetest.
Day 29 Question:
Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.
Each number in candidates may only be used once in the combination.
Note:
All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations.
Example 1:
Input: candidates = [10,1,2,7,6,1,5], target = 8,
A solution set is:
[
[1, 7],
[1, 2, 5],
[2, 6],
[1, 1, 6]
]
Example 2:
Input: candidates = [2,5,2,1,2], target = 5,
A solution set is:
[
[1,2,2],
[5]
]
Difficulty: Medium
Programming quote for the day:
“ Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ” - Martin Fowler
Day 28 Question:
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Example:
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
Difficulty: Hard
Programming quote for the day:
“ Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ” - Rick Osborne
Hope you have solved todays 25th question.
Day 25 Question:
Divide Two Integers
Solution:
https://www.prodevelopertutorial.com/divide-two-integers-without-using-multiplication-division-and-mod-operator/
Please comment with your answers in the comment section of the above post.
I request everyone to solve the questions daily, even if you have solved them earlier. It gives you good understanding about the subject.
Day 27 Question:
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists in the array.
Your algorithm's runtime complexity must be in the order of O(log n).
Example 1:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Example 2:
Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1
Difficulty: Medium
Programming quote for the day:
“ First, solve the problem. Then, write the code. ” - John Johnson
Day 26 Question:
Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place and use only constant extra memory.
Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,3 → 1,3,2
3,2,1 → 1,2,3
1,1,5 → 1,5,1
Difficulty: Medium
Programming quote for the day:
“ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. ” - Brian Kernighan
Hope you have solved Day 24rd question.
Day 24 Question:
Swap Nodes in Pairs
Solution:
https://www.prodevelopertutorial.com/swap-nodes-in-pairs/
Please comment with your answers in the comment section of the above post.
companies asked: Moonfrog Labs, Microsoft, Amazon
Hope you have solved Day 23rd question.
Day 23 Question:
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.
Solution:
https://www.prodevelopertutorial.com/merge-two-sorted-linked-lists-and-return-it-as-a-new-list-in-c/
Please comment with your answers in the comment section of the above post.
companies asked: Accolite Microsoft Amazon FactSet Flipkart Oracle Samsung MakeMyTrip Brocade
Day 25 Question:
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
Input: dividend = 10, divisor = 3
Output: 3
Difficulty: Medium
Please write your solution in comment section of the post below:
https://www.prodevelopertutorial.com/divide-two-integers-without-using-multiplication-division-and-mod-operator/
Programming quote for the day:
“ Walking on water and developing software from a specification are easy if both are frozen. ” - Edward V Berard
