Skip to content

Instantly share code, notes, and snippets.

View Haffshah's full-sized avatar
😎
Learning new things

Harsh M Shah Haffshah

😎
Learning new things
View GitHub Profile
// Remove numbers from odd position
// Sample Input : [2,5,3,4,6,7,9,8]
// Output :[5,4,7,8]
void main() {
List inputList = [2, 5, 3, 4, 6, 7, 9, 8]; // Given List
List list = []; // empty list for sepearte the output
List removedElements = [];
print("Given List : $inputList\n");
// Update the values of a list with their absolute values
// Sample Input : [2,-4,3,-1,23,-4,-54]
// Output : [2,4,3,1,23,4,54]
void main() {
absoluteList();
}
void absoluteList() {
List<int> nonAbsuolute = [2, -4, 3, -1, 23, -4, -54];
// You are given a string, str, of length N consisting of lowercase letters of alphabet. You have
// to remove all those characters from str which have already appeared in it, i.e., you have to
// keep only first occurrence of each letter.
// Sample Input : ccbabacc
// Output : cba
void main() {
removeDuplicateChar();
removeDuplicateChar2();
removeDuplicateChar3();
@Haffshah
Haffshah / sum_of_odd_num.dart
Created September 16, 2021 07:13
Return the sum of odd elements from the given list
// 1. You are given a list. Return the sum of odd elements from the given list
// Sample Input : [3,2,4,6,5,7,8,0,1]
// Output : 16
void main() {
sumOdd();
sumOdd2();
}
// Definition : PFA Array Of Student name, by using dart pad divide all students into groupof 4.
// final List<String> studentArr = <String>[
// 'Kalpit Seksariya',
// 'Gaurang Gajera',
// 'Bollam saiprakash',
// 'Dhruv Vaghela',
// 'Jaydeep Dhamecha',
// 'Jigar Pandya',
// 'Riddhi Bhavsar',
// 'Ankit Jadav',
@Haffshah
Haffshah / sublist.dart
Created September 15, 2021 11:37
Division of list into Equal parts into SubList in Dart with Easy And Lengthy Way.
// Definition : PFA Array Of Student name, by using dart pad divide all students into group of 4.
// final List<String> studentArr = <String>[
// 'Kalpit Seksariya',
// 'Gaurang Gajera',
// 'Bollam saiprakash',
// 'Dhruv Vaghela',
// 'Jaydeep Dhamecha',
// 'Jigar Pandya',
// 'Riddhi Bhavsar',
@Haffshah
Haffshah / future.dart
Created September 11, 2021 09:08
Basic use of Future keyword , asysnc and await in dart
// Use of Ansynchronous Function adn Opration in Dart
// A future represents the result of an asynchronous operation
// it's have two states: uncompleted or completed.
// To define an async function, add async before the function body
// The await keyword works only in async functions
Future<String> createOrderMessage() async {
var order = await fetchUserOrder();
return 'Your order is: $order'; // pizza
@Haffshah
Haffshah / list.dart
Created September 8, 2021 10:30
Basic Examples of List Operation in dart also Function with Name parameter and optional Parameter.
void main() {
fullName("Harsh", "Shah"); // first Name , Last Name will Print
fullName("Harsh", "Shah",
"Software Developer"); //Titel, first,last name will prints
List vehical = ['Car', 'Bike', 'Cycle', 'Truck']; //list of strings
List vehical1 = ['Ship', 'Aeroplane', 'Rocket', 'Helicopter'];
final numbers = [42, -1, 299792458, 100]; // list of integers
@Haffshah
Haffshah / Loopsin.dart
Last active September 7, 2021 11:14
Basic Example of Loop Used in Dart
// Different types of loops in Dart
// while Loop
// Do While Loop
// For loop
// For In or For Each Loop
void main() {
//Function Calling
whileLoop();
@Haffshah
Haffshah / IncrDecr.dart
Last active September 7, 2021 11:14
Basic Operation of Increment & Decrement Operators used in dart
// Types of Increment & Decrement Oprators
// +=
// -=
// *=
// /=
// (operand++)
// (operand--)
// (++operand)
// (--operand)