longestword

Run Settings
LanguageDart
Language Version
Run Command
import 'dart:io'; void main() { String LongestWord(String sen) { List<String> maxword = []; int maxsum = 0; List<String> currentword = []; for(var i = 0; i < sen.length; i++){ if(RegExp(r'[A-Za-z0-9]').hasMatch(sen[i] )){ // currentsum += 1; currentword.add(sen[i]); }else{ // if (currentword.length > maxword.length) { // maxword = List.from(currentword); // } currentword.clear(); } print(maxword); print(currentword); if(currentword.length > maxword.length ){ maxword = List.from(currentword); } } print(maxword); sen = maxword.join(' '); print(sen); // code goes here return sen; } print(LongestWord("I love dogs")); }
Editor Settings
Theme
Key bindings
Full width
Lines