This repo is for competitive coders. In the readme file you will get the list of questions. You can contribute by adding your solutions or by providing the optimized solutions which are answered already.

Hello, Problem Solvers !!!

💥 What it's about?

👩‍💻 This repository is for Competitive Coders to get started with Open-source.

📃 We have curated a list of standard problems for you to get better at DSA.

🐾 Follow these steps to get started

👉 Pick a question from the list given below.
👉 Fork this repository.
👉 Add your solution.
👉 Create pull-request.

🚀 Start contributing to this repository by adding your solutions for questions given below.


Q1. Positioning of Mirror

During the Induction program at JEC, Chef began liking a girl and wants to look at her. They are sitting in an Auditorium and you are friends with Chef. You have to place a mirror (point size) on the front wall of the hall so that Chef can have a glimpse of her. Consider the front wall as the x-axis. You are given the coordinates of the position of Chef and his Crush (x1,y1), (x2,y2) respectively. Find the position where the mirror should be placed.
Input:
The first line contains the number of test cases T.
The next T lines will have two lines:
Line one contains the coordinates of Chef.
Line two contains the coordinates of Chef’s crush.
Output:
T lines each giving the correct x-coordinate of the mirror up to two decimal places.
Sample input:
1
1 1
4 4
Sample output:
1.60
Constraints:
-109 <= x1,x2 <= 109
0 < y1, y1 <= 109


Q2. Maximum Subarray

Given an integer array nums , find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
A subarray is a contiguous part of an array.

Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Constraints :
1 <= nums.length <= 105
-10 4 <= nums[i] <= 104
Solution We will initiate two variables current_sum and max_sum initiated with zero, then iterate over array to add every element to current_sum and compare with max_sum if current sum becomes greater than max_sum it will assign max_sum the value of current_sum . And in case current_sum becomes negative we will reinitialize it with zero. Code In C++ :
#include
using namespace std;

int main(){
int n;
cin>>n;
int nums[n];
for(int i = 0;i < n;i++){
cin>>nums[i];
}
int current_sum=0,max_sum=0;
for(int i=0;i
current_sum+=nums[i];
if(current_sum > max_sum)
max_sum = current_sum;
if(current_sum < 0)
current_sum=0;
}
cout< <
return 0;
}


Q3. Trapping Rainwater

Given an array arr[] of non-negative integers representing the height of blocks. If width of each block is 1, compute how much water can be trapped between the blocks during the rainy season.

Input: arr[] = [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Rain Water Trapping
Explanation:
The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
Constraints :
1 <= nums.length <= 105
-10 4 <= nums[i] <= 104


Q4. Intersection of Two Linked Lists

Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.

Input: LinkedList1 = 3->6->9->common
LinkedList2 = 10->common
Common = 15->30->NULL
Output: 15
Intersection of two linked lists
Explanation:
Following two linked lists begin to intersect at node 15.
Constraints :
1 ≤ N + M ≤ 2*105
-1000 ≤ value ≤ 1000


Q5. Zig-Zag traversal of binary tree

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).

Input: root = [3,9,20,null,null,15,7]
Output: [ [3], [20,9], [15,7] ]
Zigzag traversal of binary tree
Explanation:
Following two linked lists begin to intersect at node 15.
Constraints :
1 ≤ N + M ≤ 2*105
-1000 ≤ value ≤ 1000


Similar Resources

cpp fundamentals and questions for beginners and intermediates

cpp fundamentals and questions for beginners and intermediates

DSA 60 days Hi people! So we have started grasping dsa concepts and solving problems from 12 July. And we shall continue till September 10 Starting fr

Sep 28, 2022

IEEEXtreme15.0 Questions And Answers

IEEEXtreme15.0 Questions And Answers

IEEEXtreme15.0 Questions And Answers IEEEXtreme is a global challenge in which teams of IEEE Student members – advised and proctored by an IEEE member

Jun 2, 2022

A challenge to solve coding questions of top 6 companies in 30 days

A challenge to solve coding questions of top 6 companies in 30 days

A challenge to solve coding questions of top 6 companies in 30 days. An initiative started by Arsh Goyal. #RevisewithArsh #6Companies30Days

Jun 29, 2022

Challenge to solve 90 questions from 6 companies in 30 days. Solved 45/90.

#RevisewithArsh #6Companies30days #dhindhora #stop #procastination #ReviseWithArsh #6Companies30Days Challenge! P.S This can be started anytime in the

Aug 21, 2022

The DSiLanguagePatcher increases accessibility to foreign region DSi consoles by providing a mean to change the user interface language.

The DSiLanguagePatcher increases accessibility to foreign region DSi consoles by providing a mean to change the user interface language.

DSi Language Patcher The DSi Language patcher is a small tool, which runs on your DSi (homebrew execution required) and create a copy of your original

May 13, 2022

Small single-header C++20 utility providing CRTP base classes for

affine_space Small single-header C++20 utility providing CRTP base classes for strongly-typed values and differences. This is similar to a very simpli

Jan 11, 2022

A curated list of project-based tutorials in C

A list of tutorials that work towards the making of small to large projects in C.

Feb 13, 2022

About Write a program to create a circular doubly linked list and perform insertions and deletions of various cases

Write a program to create a circular doubly linked list and perform insertions and deletions of various cases Circular Doubly Linked List Circular Dou

Aug 28, 2021

Hello, I am creating this file to make everyone understand the basis of C++ language which is actually the advanced version of C but better than C because of its OOPs feature.

Hello-in-C++ 😄 😄 FOR BEGINNERS IN C++ Hello, I am creating this file to make everyone understand the basics of C++ language which is actually the ad

Dec 27, 2021
📘 MIPT University - Olympiad School of Competitive Programming (C++) Curated repository with full explanations, solutions & written lectures collected throughout my academic experience at MIPT school

MIPT - Olympiad School of Competitive Programming (with C++) Outcomes: Studying at this school has allowed be to explore numerous algorithms, data str

Nov 24, 2021
I am planning to add a beginner friendly path for my Juniors to Learn DSA and I will try to provide solutions of every problem also. We can add codeChef Challenge solutions also

DSA-Path-And-Important-Questions I am planning to add a beginner friendly path for my Juniors to Learn DSA Are you a Newbie in programming and want to

Sep 7, 2022
A series of important questions with solutions to crack the coding interview and ace it!

Data-Structures-Algorithms-Handbook Ace that coding interview! A series of important questions with solutions to crack the coding interview and ace it

Sep 25, 2022
Solutions for the Questions asked during Reverse Coding 2022.
Solutions for the Questions asked during Reverse Coding 2022.

Reverse Coding 2022 Solutions for the Questions asked during Reverse Coding 2022. This is the Open-Source release of the code used in Reverse Coding 2

Aug 3, 2022
This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.

CPP-Questions-and-Solutions ?? This repository aims to solve and create new problems from different spheres of coding, which will serve as a single po

Sep 13, 2022
🧼 Cleanly pause and play your YouTube videos while cooking/crafting/doing your makeup by waving your hand over a proximity sensor!

?? Cleanly pause and play your YouTube videos while cooking/crafting/doing your makeup by waving your hand over a proximity sensor!

May 1, 2022
Programming-Basics - This Repository Contains source codes of various programming languages. Please Contribute to make this Useful.
Programming-Basics - This Repository Contains source codes of various programming languages. Please Contribute to make this Useful.

Programming-Basics About ❓ Want To Start your Open-Source Journey Without Facing Difficulties?,If Yes, Then You Are at The Right Place! ?? Don't Know

Sep 28, 2022
Competitive Programming Language MM

MM Language MM Languageは、競技プログラミングのために開発中のプログラミング言語です。 どんなことが可能なのかは、examplesおよびexamples_outputsを参照ください。 まだ開発中の言語であるため、諸々不備があり、コンパイルエラーの行数表示さえまともに出せない状

Aug 22, 2022
My evolution in competitive programming especially with C++ on differents website
My evolution in competitive programming especially with C++ on differents website

competitive-programming My evolution in competitive programming especially with C++ on differents website. A typical example of an exercise/problem We

Jun 15, 2021
Competitive Programming Basics in C++

Competitive Programming ?? ?? Hello Programmers ?? , A one-stop destination for all your Competitive Programming Resources. ?? ?? What is Competitive

May 20, 2022