adnanaziz / epicode Goto Github PK
View Code? Open in Web Editor NEWCode for Elements of Programming Interviews
License: MIT License
Code for Elements of Programming Interviews
License: MIT License
HI Adnan,
I have the book version 1.3.1, however I just realized you have an updated version mentioned in http://elementsofprogramminginterviews.com/2016-10-19-new-cover. I could not find via Amazon as it is a copy from 2012. Is this copy available somewhere?
Thank you.
the maxVolume is only generated in the current version of code, at time-interval that had trafficeVolume in the input. The in between interval maxVolume are not generated.
For example for the input
vector trafficVol = {{0, 1.3}, {2, 2.5}, {3, 3.7}, {5, 1.4}, {6, 2.6}, {8, 2.2}, {9, 1.7}, {14, 1.7}};
the output is : { 0 ,1.3 }, { 2 ,2.5 }, { 3 ,3.7 }, { 5 ,3.7 }, { 6 ,3.7 }, { 8 ,2.6 }, { 9 ,2.6 }, { 14 ,1.7 },
it should be : { 0 ,1.3 }, { 1 ,1.3 }, { 2 ,2.5 }, { 3 ,3.7 }, { 4 ,3.7 }, { 5 ,3.7 }, { 6 ,3.7 }, { 7 ,2.6 }, { 8 ,2.6 }, { 9 ,2.6 }, { 10 ,2.2 }, { 11 ,2.2 }, { 12 ,1.7 }, { 13 ,0 }, { 14 ,1.7 },
Also per diagram 22.5(b)
Unless I misunderstood the problem ?
Please update with Python version of the code
@adnanaziz @thlee-uber - I am not sure if this is the right avenue to bring this to your attention. I apologize in advance if that is indeed not the case.
This is a slight modification to the approach in permutations-alternative.cc
:
vector<vector<int>> permute_unique(vector<int> nums)
{
vector<vector<int>> result;
sort(nums.begin(), nums.end());
permute_unique_recursive(0, &nums, &result);
return result;
}
void permute_unique_recursive(int index_start, vector<int>* arr, vector<vector<int>>* result)
{
vector<int>& a = *arr;
if (index_start == arr->size() - 1) {
result->emplace_back(a);
return;
}
permute_unique_recursive(index_start + 1, arr, result);
for (int i = index_start + 1, n = arr->size(); i < n; ++i) {
if (a[index_start] == a[i])
continue;
swap(a[index_start], a[i]);
permute_unique_recursive(index_start + 1, arr, result);
}
rotate(a.begin() + index_start, a.begin() + index_start + 1, a.end());
}
I'm getting a "This site can't be reached" error when I try to visit http://elementsofprogramminginterviews.com/solutions/. Anyone else? I bought the book with the expectation of having access to online resources... Wondering if I should just return it...
In Chapter 5, problem 10, reader is asked to generate a uniformly random number within a range [a,b].
The solution provided is not uniformly random. My method to test is given here:
https://gist.github.com/umbs/5b1557b585d2ed068d7169554db1e62d
Results after multiple runs within various ranges are:
[1]
$ ./a.exe 1 10
1 = 0.000700
2 = 0.008300
3 = 0.046000
4 = 0.114200
5 = 0.206200
6 = 0.252600
7 = 0.199500
8 = 0.115600
9 = 0.045000
10 = 0.011400
==========
$ ./a.exe 10 15
10 = 0.015200
11 = 0.098200
12 = 0.235200
13 = 0.306700
14 = 0.238000
15 = 0.090900
===========
$ ./a.exe 101 120
101 = 0.000000
102 = 0.000000
103 = 0.000400
104 = 0.001300
105 = 0.005100
106 = 0.014100
107 = 0.038200
108 = 0.076600
109 = 0.115500
110 = 0.159100
111 = 0.173200
112 = 0.163000
113 = 0.119800
114 = 0.074000
115 = 0.037500
116 = 0.015400
117 = 0.005200
118 = 0.001400
119 = 0.000100
120 = 0.000100
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.