CS 199 EMP

Even More Practice

Attendance Link:

https://forms.gle/8yto1LvJ4hntiKNu7

2 meetings every week Tuesday and Thursday

  • Early CST - Early risers and Eastern timezones

  • 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?

See what students just like you were able to make:
https://cs125-old.cs.illinois.edu/info/fair/

  • Remember that Android had 3.75 billion users today, that's people you can already target with skills from CS 125. Go make the next disruptive startup!

Resources

Software Dev: 20% coding, %80 Google

Holy Grail: https://developer.android.com/

For finding APIs:

For More Coding Practice

Practice

House Robber (Leetcode):

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.

https://leetcode.com/problems/house-robber/

public int rob(int[] nums) {
  
}

hint: evens or odds?

OOP Design: (20 min)

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.

public void reverseString(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)

public int rob(int[] num) {
	if(num==null || num.length == 0)
		return 0;
 
	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;
}

see: https://www.programcreek.com/2014/03/leetcode-house-robber-java/

2)

open ended!

3)

  public void recursivehelper(char[] s, int left, int right) {
    // base case
    if (left >= right) {
      return;
    }
    
    // just keep swapping the far left and the far right
    char tmp = s[left];
    s[left++] = s[right];
    s[right--] = tmp;
    recursivehelper(s, left, right);
  }

  public void reverseString(char[] s) {
    // start at the far ends of the string
    recursivehelper(s, 0, s.length - 1);
  }
}