careercup / ctci-6th-edition-cpp Goto Github PK
View Code? Open in Web Editor NEWCracking the Coding Interview 6th Ed. C++ Solutions
Cracking the Coding Interview 6th Ed. C++ Solutions
Value 10 is larger than 5 and should be on the right hand side after partitioning.
I just referred to this practice and found that the result might be wrong if the string pattern is "TTE"
Problem 4.1 - Route Between Nodes, the solution is not available.
int checkHeight(TreeNode* root) {
if (root == nullptr) {
return 0;
}
int leftHeight = checkHeight(root->left);
if (leftHeight == -1) {
return -1;
}
int rightHeight = checkHeight(root->right);
if (rightHeight == -1) {
return -1;
}
if (abs(leftHeight - rightHeight) > 1) {
return -1;
}
else {
return max(leftHeight, rightHeight) + 1;
}
}
//wrapper function should be checkHeight != -1 ... not checkHeight == -1
bool isBalanced(TreeNode* root) {
//return (checkHeight == -1);
return (checkHeight != -1);
}
Cloning the repository on windows platform gives an error.
This is caused by an extra space character at the end of the directory name
Ch 4. Trees and Graphs
The code declares a pointer in line 10, but doesn't use pointer notation to access it
TreeNode* newNode = new TreeNode(arr[mid]);
newNode.left = createMinBST(arr, start, mid - 1); // Should be newNode->left
newNode.right = createMinBST(arr, mid + 1, end); // Should be newNode->right
Is it just pseudo code?
Should the void main
be removed in the function below?
void main std::wstring sort(const std::wstring &s)
wstring
doesn't have a member named toCharArray
on line 7.
If not, how do you compile the file?
Thanks,
I'm trying to understand why the implementation of the linked lists, as present in the class in C++, is not used. It would be easier to write, and the code would be a lot less, and cleaner.
at line 27: int extendedLen = len + 2 * numOfSpaces;
I do not really understand why we should time 2 to the numOfSpaces? why not times 3? Cause length of space =1, and length of %20=3
As Hint #132 suggests, isUniqueChars_noDS
can be implemented in O(n logn) by sorting. Also, inside main()
, the function isUniqueChars_noDS
is not tested while the function isUniqueChars_bitvector
is tested twice.
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.