අනාත programmers ලා.

duka

Active member
  • Nov 1, 2007
    260
    58
    28
    හැබැයි මූ කියන එක 100% ඇත්ත
    * gahanna code kata padam karan inna one na. Kohomath dan kale wena kota katawath code mathaka na. But thamanta logic eka therenna one pattern eka karana. oke kawuruth balaporoththu wenne an coding correcly. but pseudocode walin liyanna puluwa. godak balanne thinking pattern eka oken
     

    MINT_51

    Well-known member
  • Jan 26, 2016
    702
    1,116
    93
    Covid batches.
    Class තිබ්බට මුං campus ගිහින් තියෙන්නෙ උපරිම sem එකක් වගේ
     

    speedmalli

    Well-known member
  • Nov 22, 2011
    21,515
    17,517
    113
    Auckland
    ගොඩක් දුරට මටත් ඕක කරගන්න බැරි වෙයි.

    මම ඉස්සර වෙලාම php javascript වලින් web applications වැඩ කරල C# .net project කරල ආය ඉගනගන්න රට ආවම C++ 2D වලින් ඇප්ලිකේශන් එකක් හදන්න සෙට් උනේ හික් ගෑවුනා ඕයි. ටික දවසක් ගියාම ටික ටික වැඩේ මීටර් වෙගන ආව game එන්ජින් එකක් මුල ඉදන් හදන්න, ඊට පස්සෙ ඒකට physics දම්මලා ගේම් එකක් දුවන්න හැදුව. දැන් නම් හිතාගන්නත් බෑ එහෙම කරාද කියලත් :lol:
     

    EKGuest

    Well-known member
  • Nov 16, 2022
    3,206
    5,703
    113
    මමත් මචන් TechLead කෙනෙක්
    ඒත් අදටත් in a Interview කට්ටියක් වට කරන් Questions අහනකොට, උන් බලන් ඉදගෙන Codality or Hackerrank කෝඩ් එකක් ලියන්න කියනකොට හරි උත්තරේ එන් නෑ ඔලුවට immediately.
    පැනික් වෙනවා.ඒ නිසා ඒ ආව එවුන්ගේ අවුලක් කියලා හිතන්නෙපා මචන්.සමහර විට උනුත් පැනික් ඇති.

    ඒකයි ගොඩක් පිටරට කොම්පැණිවල ගෙදර ඉදන් කරන්න Assignment දීලා ඒක බලල තීරණය කරන්නේ.

    මට වුනෙත් ඔය දේම තමා. මම අන්තිමට ඉන්ටවීව් එකකට ගියේ 2009 දී. මගෙන් ඇහුවෙත් මේ වගේම ලේසි ප්‍රශ්න. ගිය හැම ඉන්ට්ටවීව් එකකදීම පැනික් වෙලා උත්තර දීගන්න බැරිව ගියා. ඊට පස්සෙ තමයි හිත හදාගෙන Developer ජොබ් හොයන එක නවත්තලා තාත්තා එක්ක වගා කරන්න පටන් ගත්තේ. ඒත් ප්‍රෝග්‍රෑමින් වලට ආස නිසා hobby එකක් විදියට දිගටම ෆ්‍රී වෙලාවල්වලට Coding Puzzles solve කරා.



    6th one was finding all palindromes in a string. that one was also a kind of disaster, but guess that's the 5th one which killed me.

    I could only come up with a brute force solution for this problem. The output is correct but the solution is not efficient due to the use of brute force approach.

    C#:
    using System;
    using System.Collections.Generic;
    
    internal class Program
    {
    
        static HashSet<string> FindAllPalindromes(string s)
        {
            HashSet<string> palindromes = new HashSet<string>();
    
            for (int length = 1; length <= s.Length; length++)
            {
                for (int i = 0; i + length <= s.Length; i++)
                {
                    if (IsPalindrome(s, i, i + length - 1))
                        palindromes.Add(s.Substring(i, length));
                }
            }
    
            return palindromes;
        }
    
        static bool IsPalindrome(string s, int fromIndex, int toIndex)
        {
            while (fromIndex < toIndex)
            {
                if (s[fromIndex] != s[toIndex])
                    return false;
                fromIndex++;
                toIndex--;
            }
            return true;
        }
    
        static void Main(string[] args)
        {
            Console.Write("Input string: ");
            string s = Console.ReadLine();
            Console.WriteLine("\nList of all palindromes in the string:\n");
    
            HashSet<string> palindromes = FindAllPalindromes(s);
    
            foreach (string palindrome in palindromes)
                Console.WriteLine(palindrome);
            Console.ReadLine();
        }
    
    }

    1.png


    An efficient solution can be found here: Find all distinct palindromic sub-strings of a given string
     
    Last edited:
    • Love
    Reactions: priyanka_hdp