Skip to content

Commit 7884426

Browse files
committed
Day - 82 work
1 parent c98c566 commit 7884426

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
| Current Status| Stats |
88
| :------------: | :----------: |
9-
| Total Problems | 119 |
10-
| Current Streak | 81 days |
11-
| Longest Streak | 81 ( August 17, 2015 - November 05, 2015 ) |
9+
| Total Problems | 120 |
10+
| Current Streak | 82 days |
11+
| Longest Streak | 82 ( August 17, 2015 - November 06, 2015 ) |
1212

1313
</center>
1414

@@ -158,7 +158,7 @@ Include contains single header implementation of data structures and some algori
158158
| Given a sorted array, determine index of fixed point in this array. If array does not have a fixed point return -1. An array has a fixed point when index of the element is same as index i.e. i == arr[i], Expected time complexity O(logn)| [fixedPoint.cpp](sort_search_problems/fixedPoint.cpp)|
159159
| Find the maximum element in an array which is first increasing and then decreasing. Input: arr[] = {8, 10, 20, 80, 100, 200, 400, 500, 3, 2, 1}, output : 500. Array may be strictly increasing or decreasing as well. ExpectedTime complexity is O(logn).| [findMaximum.cpp](sort_search_problems/findMaximum.cpp)|
160160
| Given an array of positive and/or negative integers, find a pair in the array whose sum is closest to 0.| [findClosestPairToZero.cpp](sort_search_problems/findClosestPairToZero.cpp)|
161-
161+
| Numeros, the Artist, had two lists A and B, such that B was a permutation of A. Numeros was very proud of these lists. Unfortunately, while transporting them from one exhibition to another, some numbers were left out of A. Can you find the missing numbers? Notes: <ul><li>If a number occurs multiple times in the lists, you must ensure that the frequency of that number in both lists is the same. If that is not the case, then it is also a missing number.</li></ul><ul><li>You have to print all the missing numbers in ascending order.</li></ul><ul><li>Print each missing number once, even if it is missing multiple times.</li></ul><ul><li>The difference between maximum and minimum number in B is less than or equal to 100.</li></ul>. <ul><li> There will be four lines of input: n - the size of the first list, This is followed by n space-separated integers that make up the first list. m - the size of the second list. This is followed by m space-separated integers that make up the second list. Output the missing numbers in ascending order.| [missingNumbers.cpp](leet_code_problems/missingNumbers.cpp)|
162162
### Graph Problems
163163
| Problem | Solution |
164164
| :------------ | :----------: |
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Problem Statement
3+
*
4+
* Numeros, the Artist, had two lists A and B, such that B was a permutation of A.
5+
* Numeros was very proud of these lists. Unfortunately, while transporting them from one exhibition to another, some numbers were left out of A.
6+
* Can you find the missing numbers?
7+
*
8+
* Notes
9+
*
10+
* If a number occurs multiple times in the lists, you must ensure that the frequency of that number in both lists is the same.
11+
* If that is not the case, then it is also a missing number.
12+
* You have to print all the missing numbers in ascending order.
13+
* Print each missing number once, even if it is missing multiple times.
14+
* The difference between maximum and minimum number in B is less than or equal to 100.
15+
* Input Format
16+
* There will be four lines of input:
17+
*
18+
* n - the size of the first list
19+
* This is followed by n space-separated integers that make up the first list.
20+
* m - the size of the second list
21+
* This is followed by m space-separated integers that make up the second list.
22+
*
23+
* Output Format
24+
* Output the missing numbers in ascending order.
25+
*/
26+
27+
#include <cmath>
28+
#include <cstdio>
29+
#include <vector>
30+
#include <iostream>
31+
#include <algorithm>
32+
#include <unordered_map>
33+
using namespace std;
34+
35+
36+
int main() {
37+
long n,m;
38+
cin >> n;
39+
long *list1 = new long[n];
40+
for (long i = 0; i < n; ++i) {
41+
cin >> list1[i];
42+
}
43+
cin >> m;
44+
long *list2 = new long[m];
45+
for (long i = 0; i < m; ++i) {
46+
cin >> list2[i];
47+
}
48+
unordered_map<long,long> hash;
49+
for (long i = 0; i < m; ++i) {
50+
hash[list2[i]]++;
51+
}
52+
for (long i = 0; i < n; ++i) {
53+
hash[list1[i]]--;
54+
}
55+
unordered_map<long,long>::iterator it;
56+
vector<long> results;
57+
for (it = hash.begin(); it != hash.end(); ++it){
58+
if ( it->second > 0) {
59+
results.push_back(it->first);
60+
}
61+
}
62+
sort(results.begin(), results.end());
63+
vector<long>::iterator i;
64+
for (i = results.begin(); i != results.end(); ++i){
65+
cout << *i << " ";
66+
}
67+
return 0;
68+
}
69+

sort_search_problems/run

44.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)