/ Published in: C#

Test 0: OK!
Test 1: OK!
Test 2: OK!
Test 3: Error: your code didn't finish in less than 2 seconds.
Test 4: Error: your code didn't finish in less than 2 seconds.
Test 5: Error: your code didn't finish in less than 2 seconds.
Test 1: OK!
Test 2: OK!
Test 3: Error: your code didn't finish in less than 2 seconds.
Test 4: Error: your code didn't finish in less than 2 seconds.
Test 5: Error: your code didn't finish in less than 2 seconds.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System; using System.Text.RegularExpressions; class MyClass { public void search_query(string[] query, string[] pages) { // Write your code here. string tokensPattern = string.Format(".*{0}.*", string.Join(".*", query)); if(query.Length > 0) { int pageCount = 0; foreach(string page in pages) { Match match = Regex.Match(page, tokensPattern); if(match.Success) pageCount++; } Console.WriteLine(pageCount.ToString()); } } }
Comments
