1/20
gotta memorize the Blind 75 somehow...
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Create a student table with student_id as an automatically incrementing primary key, name as a VARCHAR(20) that cannot be NULL, and major as a VARCHAR(20) that defaults to 'Undecided'.
CREATE TABLE student (
student_id INT AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
major VARCHAR(20) DEFAULT 'Undecided',
PRIMARY KEY(student_id)
);What do NOT NULL, UNIQUE, PRIMARY KEY, DEFAULT, and AUTO_INCREMENT do when creating a MySQL table?
NOT NULL → the column must have a value.
UNIQUE → every value in the column must be unique.
PRIMARY KEY → the column is NOT NULL and UNIQUE.
DEFAULT → provides a value when one is not specified.
AUTO_INCREMENT → automatically increases an INT value when a new row is added.
Create a student table with student_id as an automatically incrementing primary key, name as a VARCHAR(20), major as a VARCHAR(20), and email as a VARCHAR(50) that must be unique.
CREATE TABLE student (
student_id INT AUTO_INCREMENT,
name VARCHAR(20),
major VARCHAR(20),
email VARCHAR(50) UNIQUE,
PRIMARY KEY(student_id)
);What is the general syntax for updating values in an SQL table, and what happens if you omit WHERE?
UPDATE table_name
SET column_name = value
WHERE condition;WHERE determines which rows are updated. Without WHERE, the update applies to every row.
What is the general syntax for deleting rows from an SQL table, and how is DELETE different from DROP?
.
DELETE FROM table_name
WHERE condition;Without WHERE, DELETE removes all rows but leaves the table itself. DROP removes the entire table.
How can an SQL query be written across multiple lines?
SQL queries can extend across multiple lines as long as the statement is not ended with a semicolon (;). The semicolon marks the end of the query.
In the student table, change every major value of 'Biology' to 'Bio'.
UPDATE student
SET major = 'Bio'
WHERE major = 'Biology';In the student table, delete the student whose student_id is 4.
DELETE FROM student
WHERE student_id = 4;What do *, dot notation (table.column), ORDER BY, and DESC do in a SELECT query?
* selects everything. table.column explicitly references a column from a particular table. ORDER BY sorts results in natural order, while DESC reverses that order. You can ORDER BY a column even if it is not included in SELECT.
What do LIMIT, comparison operators, and IN do when filtering SQL results?
LIMIT restricts how many rows are returned. SQL supports basic comparisons such as =, >, and <; <> means not equal. IN checks whether a value matches one of several specified values.
From the student table, return each student's name and student_id, ordered by their major.
SELECT student.name, student.student_id
FROM student
ORDER BY student.major;From the student table, return all columns for the first 2 rows when the table is in its natural order.
SELECT *
FROM student
LIMIT 2;From the student table, return the student_id of students whose major is 'Comp. Sci' and whose student_id is greater than 2.
SELECT student.student_id
FROM student
WHERE major IN ('Comp. Sci') AND student.student_id > 2;What are the two types of interval problems? What are clues to use each?
Processing intervals together & separating start/ends
Separate: Find # of overlapping intervals at any given moment (Meeting Rooms II; minimum # of meeting rooms)
Together: Everything else
3Sum Time Complexity & Strategy
O(n²) expected
Insight: sort array, then treat as combo of TwoSum & Valid Palindrome
Set L as leftmost, subtract from 0 to get target, then scan inwards with L & R until finding correct sum
Avoid duplicates by skipping over repeated L and M/R values (sorted; this works)
Search in Rotated Sorted Array: TC & Insight
Classic Binary Search: O(log n); L, M, and R pointers
Split into cases & use logic: if [L] > [M], which side is normally sorted (ascending?)
Use that knowledge to slice up the rest of the remaining array
Longest Substring Without Repeating Characters: TC & Insight
O(n); single-pass
Insight: use a dict (or set) to count which characters are already seen; add new ones with R, remove ones with L
Find size using R - L (rather than sum(d.values())) for better time efficiency (or just use a set)
Product of Array Except Self: TC & Insight
TC: O(n) [required by problem]
Use two separate arrays: one for prefix sums (“everything before X”) and suffix sums (“everything after X”); cross multiply to get product of “everything except X”
Use 2 extra arrays
Remove Nth Node from End of List: TC & Insight
O(n) [technically O(2n)]
looping over list once gets length; subtracting this length from (given) n tells you how many times to loop to get to n
Loop until reaching n (toRemove), then update
Don’t forget about edge cases + updating head node
Palindromic Substring: TC & Insight
O(n²) expected
NOT sliding window
Expand outwards from each character, checking for even & odd palindromes
Increment count for each additional palindrome found
Longest Palindromic Substring: TC & Insight
O(n²) expected
Same as Palindromic Substrings: expand outwards from each char, checking for even and odd length palindromes
Watch for edge cases with slicing ( >= 0 and X + 2 + C)
Use pointer indices to record substrings rather than calculating string subarrays each time for extra time saving