Created
March 16, 2018 12:51
-
-
Save cosminpopescu14/0aa43ae3cc84da3b22c98f1cc27df68b to your computer and use it in GitHub Desktop.
My solution (or a trial) to Run Length Encoding (Function Problem)
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication11 | |
{ | |
//https://practice.geeksforgeeks.org/problems/run-length-encoding/1#ExpectOP | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string input = "relax Don't do it"; | |
var freq = from x in input | |
group x by x into y | |
select y; | |
foreach (var item in freq) | |
{ | |
Console.WriteLine(string.Join("--", item.First(), item.Count())); | |
//Console.WriteLine(item.First().ToString() + item.Count().ToString()); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My attempt at least !