Skip to content

Commit 35e0a26

Browse files
committed
update
1 parent 4e9d98c commit 35e0a26

12 files changed

+192
-10
lines changed

Diff for: algorithms

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 43eb9660394525c2204b96c19d0337681202f870

Diff for: cpp/3

8.68 KB
Binary file not shown.

Diff for: cpp/a.out

8.68 KB
Binary file not shown.

Diff for: cpp/basicdatatypes.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
using namespace std;
4+
5+
int main() {
6+
int a;
7+
long b;
8+
long long c;
9+
char d;
10+
float e;
11+
double f;
12+
scanf("%d %ld %lld %c %f %lf", &a, &b, &c, &d, &e, &f);
13+
printf("%d %ld %lld %c %f %lf", a, b, c, d, e, f );
14+
return 0;
15+
}

Diff for: cpp/inputoutput.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <cmath>
2+
#include <cstdio>
3+
#include <vector>
4+
#include <iostream>
5+
#include <algorithm>
6+
using namespace std;
7+
8+
9+
int main() {
10+
int a, b, c, sum;
11+
cin >> a >> b >> c;
12+
sum = a + b + c;
13+
cout << a+b+c;
14+
return 0;
15+
}
16+

Diff for: datastructures/1

8.56 KB
Binary file not shown.

Diff for: datastructures/insertendll.cpp

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
struct Node{
5+
int data;
6+
Node* next;
7+
};
8+
9+
/*
10+
Node* Insert(Node* head, int data){
11+
Node* curr = head;
12+
Node* add = new Node;
13+
add->data = data;
14+
add->next = NULL;
15+
while (curr->next != NULL){ //trying to access null object right here
16+
curr=curr->next;
17+
}
18+
curr->next = add;
19+
if (!head)
20+
head = add;
21+
return head;
22+
};
23+
*/
24+
25+
Node* Insert(Node* head, int data){
26+
Node* add = new Node;
27+
add->data = data;
28+
add->next = NULL;
29+
//empty case
30+
if (!head){
31+
//account
32+
head = add;
33+
} else {
34+
Node* curr = head;
35+
while (curr->next){
36+
curr = curr->next;
37+
}
38+
curr->next = add;
39+
}
40+
return head;
41+
}
42+
43+
44+
void Print (Node *head) {
45+
Node* curr = head;
46+
while (curr){
47+
printf("%d\n", curr->data);
48+
curr=curr->next;
49+
}
50+
}
51+
52+
int main(){
53+
Node* test = new Node();
54+
test->data = 4;
55+
test->next = NULL;
56+
57+
Insert(Insert(Insert(test, 3), 9),0);
58+
Print(test);
59+
60+
Print(Insert(NULL, 2));
61+
return 0;
62+
}

Diff for: datastructures/linkedlist-2.cpp renamed to datastructures/insertheadll.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ Node* Insert(Node *head, int data){
1111
Node* curr = head;
1212
Node* addon = new Node();
1313
addon->data = data;
14-
curr->next = addon;
15-
if (!head)
16-
return addon;
17-
18-
while (curr->next){
19-
curr = curr->next;
20-
}
21-
22-
return head;
14+
addon->next = curr;
15+
return addon;
2316
}
2417

2518
void Print (Node *head) {

Diff for: datastructures/insertnthposll.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
struct Node{
5+
int data;
6+
Node* next;
7+
};
8+
9+
10+
Node* Insert(Node *head, int data, int position){
11+
Node* curr = head;
12+
Node* addon = new Node();
13+
addon->data = data;
14+
for (int i = 0; i < position; i++){
15+
curr = curr->next;
16+
17+
}
18+
19+
20+
return head;
21+
}
22+
23+
void Print (Node *head) {
24+
Node* curr = head;
25+
while (curr){
26+
printf("%d\n", curr->data);
27+
curr=curr->next;
28+
}
29+
}
30+
31+
int main(){
32+
Node* test = new Node();
33+
test->data = 4;
34+
test->next = NULL;
35+
36+
Node* test2 = new Node();
37+
test2->data = 2;
38+
test2->next = test;
39+
40+
Insert(Insert(Insert(test2, 3), 4), 1);
41+
Print(test2);
42+
43+
return 0;
44+
}

Diff for: datastructures/linkedlist-4.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
struct Node{
5+
int data;
6+
Node* next;
7+
};
8+
9+
10+
Node* InsertNth(Node* head, int data, int position){
11+
//create new node
12+
Node* add = new Node();
13+
add->data = data;
14+
add->next = NULL;
15+
//empty list
16+
if (!head){
17+
head = add;
18+
} else {
19+
Node* curr = head;
20+
while (curr->next)
21+
curr = curr->next;
22+
23+
24+
25+
26+
27+
28+
};
29+
return head;
30+
};

Diff for: datastructures/linkedlist-1.cpp renamed to datastructures/printll.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ struct Node {
77
struct Node* next;
88
};
99

10-
1110
void Print (Node *head) {
1211
Node* curr = head;
1312
while (curr){

Diff for: schedule.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
oct 10 - finish linked lists, start BST, one chapter C++, three problems from CTCI
2+
oct 11 - BST, review Facebook working environment, one chapter C++, three problems from cTCI
3+
oct 12 - BST, review Facebook's working tools, one chapter C++, three problems form CTCI
4+
oct 13 - algorithms, read on glassdoor, review Javascript Definitive Guide stuff, three problems from CTCI
5+
oct 14 -
6+
oct 15
7+
oct 16
8+
apply to other internships:
9+
dropbox
10+
airbnb
11+
apple
12+
amazon
13+
linkedin
14+
paypal
15+
intel
16+
xerox
17+
cisco
18+
oracle
19+
hp
20+
uber
21+
22+

0 commit comments

Comments
 (0)