예제 #1
0
        static stringData LengthOfLongestSubstring(string s)
        {
            int        n     = s.Length;
            int        ans   = 0;
            int        start = 0;
            int        end   = 0;
            stringData sd    = new stringData();

            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    if (allUnique(s, i, j))
                    {
                        if ((j - i) > ans)
                        {
                            start = i;
                            end   = j;
                            ans   = Math.Max(ans, j - i);
                        }
                    }
                }
            }
            sd.start        = start;
            sd.end          = end;
            sd.stringLength = ans;
            return(sd);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            string     s  = "heuwoqrlaslkslklllsdfjdskcmmdmmmdssdfff";
            stringData sd = LengthOfLongestSubstring(s);

            Console.WriteLine(sd.stringLength);
            Console.WriteLine("The longest string is {0}, with a length of {1} characters", s.Substring(sd.start, sd.end), sd.stringLength);
        }
예제 #3
0
        public static void CreateProjectResxStrings(int projectId, int resxId)
        {
            var proj = (from p in  _context.projects where p.id == projectId select p).SingleOrDefault();

            if (proj == null)
            {
                return;
            }
            var resx = (from r in _context.resxItems where r.id == resxId select r).SingleOrDefault();

            if (resx == null)
            {
                return;
            }
            foreach (var lang in proj.langs)
            {
                var resxString = new stringData {
                    lang_id = lang.id, resxItem_id = resxId
                };
                resx.stringDatas.Add(resxString);
            }
            _context.SaveChanges();
        }