This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <unordered_map> | |
using namespace std; | |
int main(){ | |
int n,m; | |
cin >> n; | |
int arr1[n]; | |
unordered_map<int,int> mp; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
void longestConsecutive(vector<int> &num) { | |
unordered_map<int,bool>mp; | |
for (int i=0;i<num.size();i++){ | |
mp[num[i]]=true; | |
} | |
for (int i=0;i<num.size();i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int findKthLargest(vector<int> const &arr, int k) | |
{ | |
priority_queue<int, vector<int>, greater<int>> pq; | |
for(int i=0;i<k;i++){ | |
pq.push(arr[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
int n; | |
cin >> n; | |
int arr[n]; | |
for(int i=0;i<n;i++){ | |
cin >> arr[i]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <queue> | |
using namespace std; | |
class MedianPriorityQueue { | |
public: | |
priority_queue <int> left; | |
priority_queue <int, vector<int>, greater<int>> right; | |
void push(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
This problem is very similar to the star triangle pattern. Just in place of stars, now we have to print numbers in increasing order. The number of rows is equal to the input value "n" and each row has as many numbers in it, but maintaining the existing increasing sequence. | |
Question Name: | |
Pattern 11 | |
Question Link: https://www.pepcoding.com/resources/online-java-foundation/patterns/design-pattern-11-official/ojquestion | |
Question Statement: | |
1. You are given a number n. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
We have to print a triangle of Fibonacci sequence numbers in the given problem. Now, we have already discussed how to print Fibonacci series and triangle of stars on the way to this problem. | |
Question Name: | |
Pattern 12 | |
Question Link: https://www.pepcoding.com/resources/online-java-foundation/patterns/design-pattern-12-official/ojquestion | |
Question Statement: | |
1. You are given a number n. | |
2. You've to create a pattern as shown in output format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
We need a triangle of numbers, so let us focus on the aspects of content of the pattern and shape of the pattern one by one. | |
Question Name: | |
Pattern 13 | |
Question Link: https://www.pepcoding.com/resources/online-java-foundation/patterns/design-pattern-13-official/ojquestion | |
Question Statement: | |
1. You are given a number n. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
We have to print a multiplication table of given number "x". We run a loop until 10. Saving results of multiplication for print command convenience and write the print command according to the output format. | |
Question Name: | |
Pattern 14 | |
Question Link: https://www.pepcoding.com/resources/online-java-foundation/patterns/design-pattern-14-official/ojquestion | |
Question Statement: | |
1. You are given a number n. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
We have already a programmed a similar design pattern consisting of only stars (Diamond; Pattern 5). | |
We will follow a set procedure to reach the required output format in the problem. | |
Question Name: | |
Pattern 15 | |
Question Link: https://www.pepcoding.com/resources/online-java-foundation/patterns/design-pattern-15-official/ojquestion | |
Question Statement: |
OlderNewer