This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
To be honest, I am doing extensive UNIX shell programming for over 20 years now and as (far as I can remember) I never had to use “$?”even once (and “$!” maybe 5 or 6 times in all those years – I actually had to look both of them up right now to see what they are standing for…). Which of course means that – according to your test – I am not very experienced regarding shell programming, am I?
Asking for something which can be found out with a simple ‘man bash’ when I need it is IMHO not a good way to check how experienced people are, but how good their memorizing skills are. Most people mix those two things up all the times. In my personal experience most of the people who can memorize everything aren’t always the best programmers (I often found that quite the opposite is actually true, besides some remarkable exceptions), but of course YMMV…
The same is true when asking for some exotic options to well known commands (e.g. asking what the option “-h” of tar does – do you know
http://www.cs.princeton.edu/academics/catalog
""" | |
class Solution { | |
public: | |
int numTrees(int n) { | |
if (n == 1) | |
return 1; | |
int res = 0; | |
// for each of the middle nodes, the number is the product of its left and right children | |
for (int i = 2; i <= n - 1; ++i) |
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: |
/** | |
* Definition for binary tree with next pointer. | |
* struct TreeLinkNode { | |
* int val; | |
* TreeLinkNode *left, *right, *next; | |
* TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: |
class Solution { | |
public: | |
int searchInsert(int A[], int n, int target) { | |
int low = 0, high = n; | |
// search in the interval A[low, high) | |
while (low < high) { | |
// loop invariant | |
// 1) 0 <= low < high <= n | |
// 2) (low == 0 || A[low - 1] < target) | |
// 3) (high == n || A[high] > target) |
#include <limits> | |
class Solution { | |
public: | |
int maxSubArray(int A[], int n) { | |
if (n == 1) | |
return A[0]; | |
auto mid = n / 2; | |
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: |