Evening CST - Western timezones (and really late Eastern folks)
Calendar contains zoom links
Attend 7 sessions for credit, attendence via google form.
We are almost there!
Thank you all for coming too these sessions! We definitely did not go easy on you guys, but you still really wanted to learn.
I hope that you keep it up over break and into your other cs classes!
THANK YOU !!!
What Now?
Now that you guys have the basics down
OOP
Trees, Arrays, Lists, Maps
Iteration, Recursion
It's time to get a sneak peek of what you can/will use moving forward
Android
The final project got cancelled this year, but that doesn't mean you can't make one! Now that you've seen one working (MP), What could be possible?
You are a planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint
stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the
police if two adjacent houses were broken into. Given an array of ints representing the amount of money of each house, find max ammount of money you can rob without alerting the police.
Some interviews will ask you more open-ended design questions, lets practice one!
Let's say your boss asked you to design a project to represent Santa's workshop. Automation is a thing, the elves are actually robots, all of them.
What sorts of objects/classes would you need? What would their attributes need to be?
of theese attributes, which objects/variables/methods would be public and private
how would each object be identified? (some sort of unique key)
What would their methods do? What would their runtime be?
Design theese in the 125 playground this question is open-ended, so use your creativity!
Problem (10 minutes)
A string is litterally an array of chars, always has been. Write a function that would reverse this sequence of chars in place.
This means you don't create any new arrays or copies of arrays.
publicvoidreverseString(char[] s){
}
hint: recursion or iteration works pretty well, think it out
Solutions
(no peeking, it's for your own good!)
(no seriously, attempt the problems with your groupmates first!)
1)
publicintrob(int[] num){
if(num==null || num.length == 0)
return0;
int even = 0;
int odd = 0;
for (int i = 0; i < num.length; i++) {
if (i % 2 == 0) {
even += num[i];
even = even > odd ? even : odd;
} else {
odd += num[i];
odd = even > odd ? even : odd;
}
}
return even > odd ? even : odd;
}
publicvoidrecursivehelper(char[] s, int left, int right){
// base caseif (left >= right) {
return;
}
// just keep swapping the far left and the far rightchar tmp = s[left];
s[left++] = s[right];
s[right--] = tmp;
recursivehelper(s, left, right);
}
publicvoidreverseString(char[] s){
// start at the far ends of the string
recursivehelper(s, 0, s.length - 1);
}
}