This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student { | |
final String name; | |
final int id; | |
final List<String> enrolledCourses; | |
Student({required this.name, required this.id, List<String>? initialCourses}) | |
: enrolledCourses = initialCourses ?? []; | |
void enrollInCourse(String course) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<dynamic> fizzbuzzOutputList = []; | |
for (int i = 1; i <= 100; i++) { | |
final bool divisibleBy3 = i % 3 == 0; | |
final bool divisibleBy5 = i % 5 == 0; | |
String? output; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int romanToInt(String s) { | |
Map<String, int> romanMap = { | |
'I': 1, | |
'V': 5, | |
'X': 10, | |
'L': 50, | |
'C': 100, | |
'D': 500, | |
'M': 1000, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<List<int>> generatePascalsTriangle(int numRows) { | |
if (numRows <= 0) return []; | |
List<List<int>> triangle = [[1]]; | |
for (int i = 1; i < numRows; i++) { | |
List<int> prevRow = triangle[i - 1]; | |
List<int> row = [1]; | |
for (int j = 1; j < i; j++) { |