UCSD CSE Summer Series

Hi all!

If you’re getting this email, I think you’re an incoming UCSD CSE transfer student this fall. Welcome!

👋🏻 CSE Summer Series

My name is Joe, I’m a professor in the CSE department. I teach several lower division courses (you may end up taking CSE29 with me in the fall!).

As part of CSE Summer Series, a free online summer program run by the department, I’ll be reaching out with weekly emails until fall quarter starts, will be providing bunch of different resources:

Do Now! (Do one, some, or all!)

🔗 Links and Resources

The code from the welcome video is also copied here for your reference:

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        for i in range(0, len(nums)):
            for j in range(i + 1, len(nums)): #note j and i are never equal
                if nums[i] + nums[j] == target:
                    return [i, j]
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
    int* result = calloc(sizeof(int), 2); // create an array with 2 elements of size int
    for(int i = 0; i < numsSize; i += 1) {
        for(int j = i + 1; j < numsSize; j += 1) {
            //printf("%d %d %d %d\n", i, j, nums[i], nums[j]);
            if(nums[i] + nums[j] == target) {
                result[0] = i;
                result[1] = j;
                *returnSize = 2;

                //printf("%d %d\n", result[0], result[1]);
                return result;
            }
        }
    }
    return NULL;
}
class Solution {
    public int[] twoSum(int[] nums, int target) {
        for(int i = 0; i < nums.length; i += 1) {
            for(int j = i + 1; j < nums.length; j += 1) {
                if(nums[i] + nums[j] == target) {
                    int[] toReturn = { i, j };
                    return toReturn;
                }
            }
        }
        return null;
    }
}