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 Medicine { | |
| var name,brand,typeOf; | |
| int expiry; | |
| Medicine( | |
| var medicineName, var medicineBrand, int expiryYear, var typeOfMedicine) { | |
| name = medicineName; | |
| brand = medicineBrand; | |
| expiry = expiryYear; | |
| typeOf = typeOfMedicine; |
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() { | |
| String name = "virajz"; | |
| List<int> chars = name.runes.toList(); | |
| print(chars); | |
| for(int i = chars.length-1, j=0 ; i >= chars.length/2 ;i--, j++){ | |
| var temp = chars[i]; // i=4, j // i=3, a // i=2, j=2 | |
| chars[i] = chars[j]; // j=0, [virav] // j=1 [jiriv] | |
| chars[j] = temp; // [jirav] // [jariv] | |
| if(i == chars.length/2){ | |
| break; |
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() { | |
| String name = "radar"; | |
| List<int> chars = name.runes.toList(); | |
| print(checkpallindrom(chars)); | |
| } | |
| bool checkpallindrom(List<int> chars) { | |
| for (int i = chars.length - 1, j = 0; i >= chars.length ~/ 2; i--, j++) { | |
| if (chars[i] != chars[j]) return false; |
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
| main() { | |
| print(insertionSort([8,9, 4, 2, 6,10,12])); | |
| } | |
| List<int> insertionSort(List<int> list) { | |
| for (int j = 1; j < list.length; j++) { | |
| int key = list[j]; | |
| int i = j - 1; |
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
| main() { | |
| print(insertionSort([8,9, 4, 2],3)); | |
| } | |
| bool insertionSort(List<int> list,int value) { | |
| for (int i = 0; i < list.length; i++) { | |
| if(value==list[i]){ | |
| return true; | |
| } | |
| } | |
| return false; |
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
| main(){ | |
| print(mergeSort([2,5,4,8,9])); | |
| } | |
| List<int> mergeSort(List<int> list){ | |
| int n = list.length; | |
| if(n<2){ | |
| return list; | |
| } | |
| int midIndexOfList = (n/2).floor(); | |
| List<int> leftList = new List(midIndexOfList); |
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
| main() { | |
| print(selectionSort([8, 18, 11, 44, 11, 11, 345, 222, 864, 44])); | |
| } | |
| List<int> selectionSort(List<int> list) { | |
| for (int j = 0; j < list.length - 1; j++) { | |
| int min = j; | |
| for (int i = j + 1; i < list.length; i++) { | |
| if (list[i] < list[j]) { | |
| min = i; |
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
| main() { | |
| print(bubbleSort([8, 4, 6, 5])); | |
| } | |
| List<int> bubbleSort(List<int> list) { | |
| for (int j = 1; j < list.length; j++) { | |
| int x = 0; | |
| for (int i = 0; i < list.length - j; i++) { | |
| if (list[i] > list[i + 1]) { | |
| int key = list[i + 1]; |
OlderNewer