{"id":118905,"date":"2026-07-13T19:18:45","date_gmt":"2026-07-13T13:48:45","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/"},"modified":"2026-07-13T19:18:47","modified_gmt":"2026-07-13T13:48:47","slug":"infosys-sp-dse-coding-questions-with-answers-2026","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/","title":{"rendered":"Infosys Coding Questions for SP and DSE (With Answers)"},"content":{"rendered":"\n<p>The <strong>Infosys Specialist Programmer (SP)<\/strong> and <strong>Digital Specialist Engineer (DSE)<\/strong> coding rounds are designed to assess your problem-solving skills, coding proficiency, and understanding of data structures and algorithms.&nbsp;<\/p>\n\n\n\n<p>Practicing the right coding questions is one of the most effective ways to improve your performance in these competitive assessments.<\/p>\n\n\n\n<p>In this guide, we've compiled some of the most frequently asked <strong>Infosys SP and DSE coding questions<\/strong>, along with their approaches and sample solutions.&nbsp;<\/p>\n\n\n\n<p>If you're looking for a comprehensive preparation roadmap, be sure to check out our <a href=\"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-interview-guide-2026\/\"><strong>Infosys SP &amp; DSE Interview Guide 2026<\/strong><\/a>, which covers the latest selection process, interview rounds, eligibility criteria, and expert preparation tips.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"most-asked-infosys-sp-and-dse-coding-questions\"><strong>Most Asked Infosys SP and DSE Coding Questions&nbsp;<\/strong><\/h2>\n\n\n\n<p>This is the section that matters most. Here are the actual topic areas and example problems drawn from Infosys coding interview questions and answers from previous years.<\/p>\n\n\n\n<p><strong>Learn to Code Under Pressure:<\/strong> Time management is key. The <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/ace-coding-interviews\">Ace Coding Interviews<\/a> free course provides a structured framework for tackling common interview patterns effectively.\u00a0<\/p>\n\n\n\n<p>Additionally, watching a professional breakdown of problems on YouTube, such as <a href=\"https:\/\/www.youtube.com\/watch?v=VhC5jFRrI6o\">Common coding interview problems | Coding Interview Questions &amp; Answers<\/a>, visually reinforces how to approach unseen questions methodically by explaining the logic step by step before touching the keyboard.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"easy-level-coding-questions\"><strong>Easy Level Coding Questions<\/strong><\/h2>\n\n\n\n<p><strong>1. Kadane's Algorithm&nbsp; Maximum Subarray Sum<\/strong><\/p>\n\n\n\n<p>One of the most frequently appearing easy questions.<\/p>\n\n\n\n<p><em>Problem:<\/em> Given an array of integers, find the contiguous subarray with the largest sum.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff374fe6\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  [-<span class=\"nm\">2<\/span>, <span class=\"nm\">1<\/span>, -<span class=\"nm\">3<\/span>, <span class=\"nm\">4<\/span>, -<span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">1<\/span>, -<span class=\"nm\">5<\/span>, <span class=\"nm\">4<\/span>]\nOutput: <span class=\"nm\">6<\/span>\nExplanation: [<span class=\"nm\">4<\/span>, -<span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">1<\/span>] has the maximum sum = <span class=\"nm\">6<\/span><\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Maintain a running sum. If the running sum goes negative, reset it to zero. Track the maximum seen so far.<\/p>\n\n\n\n<div id=\"copy-6a5deff37500f\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">maxSubArray<\/span>(nums):\n    max_sum = nums[]\n    current_sum = nums[]\n    <span class=\"kw\">for<\/span> num <span class=\"kw\">in<\/span> nums[<span class=\"nm\">1<\/span>:]:\n        current_sum = <span class=\"fn\">max<\/span>(num, current_sum + num)\n        max_sum = <span class=\"fn\">max<\/span>(max_sum, current_sum)\n    <span class=\"kw\">return<\/span> max_sum<\/code><\/pre><\/div>\n\n\n\n<p><strong>2. Next Greater Element<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Given an array, for each element return the first greater element to its right. Return -1 if no such element exists.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff375025\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  [<span class=\"nm\">1<\/span>, <span class=\"nm\">3<\/span>, <span class=\"nm\">2<\/span>]\nOutput: [<span class=\"nm\">3<\/span>, -<span class=\"nm\">1<\/span>, -<span class=\"nm\">1<\/span>]<\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Use a monotonic stack. Traverse right to left and maintain a decreasing stack.<\/p>\n\n\n\n<div id=\"copy-6a5deff37506b\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">nextGreaterElement<\/span>(nums):\n    result = [-<span class=\"nm\">1<\/span>] * <span class=\"fn\">len<\/span>(nums)\n    stack = []\n    <span class=\"kw\">for<\/span> i <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(<span class=\"fn\">len<\/span>(nums) - <span class=\"nm\">1<\/span>, -<span class=\"nm\">1<\/span>, -<span class=\"nm\">1<\/span>):\n        <span class=\"kw\">while<\/span> <span class=\"fn\">len<\/span>(stack) &gt;  <span class=\"kw\">and<\/span> stack[-<span class=\"nm\">1<\/span>] &lt;= nums[i]:\n            stack.<span class=\"fn\">pop<\/span>()\n        <span class=\"kw\">if<\/span> stack:\n            result[i] = stack[-<span class=\"nm\">1<\/span>]\n        stack.<span class=\"fn\">append<\/span>(nums[i])\n    <span class=\"kw\">return<\/span> result<\/code><\/pre><\/div>\n\n\n\n<p><strong>3. Rotate Array by K Positions<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Rotate an array of n elements to the right by k steps.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff37508a\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  [<span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">3<\/span>, <span class=\"nm\">4<\/span>, <span class=\"nm\">5<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">7<\/span>], k = <span class=\"nm\">3<\/span>\nOutput: [<span class=\"nm\">5<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">7<\/span>, <span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">3<\/span>, <span class=\"nm\">4<\/span>]<\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Reverse the entire array, then reverse the first k elements, then reverse the remaining n-k elements. Time complexity O(n), Space O(1).<\/p>\n\n\n\n<div id=\"copy-6a5deff3750d3\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">rotateArray<\/span>(nums, k):\n    n = <span class=\"fn\">len<\/span>(nums)\n    k = k % n  <span class=\"cm\"># Handle cases where k &gt; n<\/span>\n\n    <span class=\"kw\">def<\/span> <span class=\"fn\">reverse<\/span>(left, right):\n        <span class=\"kw\">while<\/span> left &lt; right:\n            nums[left], nums[right] = nums[right], nums[left]\n            left += <span class=\"nm\">1<\/span>\n            right -= <span class=\"nm\">1<\/span>\n\n    <span class=\"fn\">reverse<\/span>(, n - <span class=\"nm\">1<\/span>)   <span class=\"cm\"># Step 1: Reverse entire array<\/span>\n    <span class=\"fn\">reverse<\/span>(, k - <span class=\"nm\">1<\/span>)   <span class=\"cm\"># Step 2: Reverse first k elements<\/span>\n    <span class=\"fn\">reverse<\/span>(k, n - <span class=\"nm\">1<\/span>)   <span class=\"cm\"># Step 3: Reverse remaining elements<\/span>\n    <span class=\"kw\">return<\/span> nums\n\n<span class=\"cm\"># Test<\/span>\n<span class=\"fn\">print<\/span>(<span class=\"fn\">rotateArray<\/span>([<span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">3<\/span>, <span class=\"nm\">4<\/span>, <span class=\"nm\">5<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">7<\/span>], <span class=\"nm\">3<\/span>))\n<span class=\"cm\"># Output: [5, 6, 7, 1, 2, 3, 4]<\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Build Your Core Competency:<\/strong> Before tackling advanced development, ensure your foundations are rock solid with the <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/programming-basics\">Programming Basics free course<\/a>. This beginner-friendly module on Great Learning Academy helps you grasp core programming logic, syntax, and fundamental coding paradigms through self-paced video lectures, culminating in a free certificate of completion.&nbsp;<\/p>\n\n\n\n<p>Additionally, if you are eyeing backend DSE roles, the <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/python-foundations\">Python Foundations course<\/a> is an excellent starting point to understand variables, loops, and basic Python syntax from scratch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"medium-level-coding-questions\"><strong>Medium Level Coding Questions<\/strong><\/h2>\n\n\n\n<p><strong>4. Longest Common Subsequence (Dynamic Programming)<\/strong><\/p>\n\n\n\n<p>One of the most commonly asked medium-level Infosys SP and DSE coding questions.<\/p>\n\n\n\n<p><em>Problem:<\/em> Given two strings, find the length of their longest common subsequence.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff3750ef\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  s1 = <span class=\"st\">&quot;ABCBDAB&quot;<\/span>, s2 = <span class=\"st\">&quot;BDCAB&quot;<\/span>\nOutput: <span class=\"nm\">4<\/span>\nExplanation: <span class=\"st\">&quot;BCAB&quot;<\/span> is the LCS<\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Classic 2D DP. dp[i][j] represents LCS of first i characters of s1 and first j characters of s2.<\/p>\n\n\n\n<div id=\"copy-6a5deff375123\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">lcs<\/span>(s1, s2):\n    m, n = <span class=\"fn\">len<\/span>(s1), <span class=\"fn\">len<\/span>(s2)\n    dp = [[] * (n + <span class=\"nm\">1<\/span>) <span class=\"kw\">for<\/span> _ <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(m + <span class=\"nm\">1<\/span>)]\n    <span class=\"kw\">for<\/span> i <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(<span class=\"nm\">1<\/span>, m + <span class=\"nm\">1<\/span>):\n        <span class=\"kw\">for<\/span> j <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(<span class=\"nm\">1<\/span>, n + <span class=\"nm\">1<\/span>):\n            <span class=\"kw\">if<\/span> s1[i-<span class=\"nm\">1<\/span>] == s2[j-<span class=\"nm\">1<\/span>]:\n                dp[i][j] = dp[i-<span class=\"nm\">1<\/span>][j-<span class=\"nm\">1<\/span>] + <span class=\"nm\">1<\/span>\n            <span class=\"kw\">else<\/span>:\n                dp[i][j] = <span class=\"fn\">max<\/span>(dp[i-<span class=\"nm\">1<\/span>][j], dp[i][j-<span class=\"nm\">1<\/span>])\n    <span class=\"kw\">return<\/span> dp[m][n]<\/code><\/pre><\/div>\n\n\n\n<p><strong>5. Number of Islands (BFS\/DFS on Grid)<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Given a 2D grid of '1's (land) and '0's (water), count the number of islands. An island is formed by connecting adjacent lands horizontally or vertically.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff375131\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:\n<span class=\"nm\">11110<\/span>\n<span class=\"nm\">11010<\/span>\n<span class=\"nm\">11000<\/span>\n<span class=\"nm\">00000<\/span>\nOutput: <span class=\"nm\">1<\/span><\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Use BFS or DFS. Whenever you find a '1', trigger a BFS to mark all connected land cells as visited. Increment the island count each time you start a new BFS.<\/p>\n\n\n\n<div id=\"copy-6a5deff375232\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">from<\/span> collections <span class=\"kw\">import<\/span> deque\n\n<span class=\"kw\">def<\/span> <span class=\"fn\">numIslands<\/span>(grid):\n    <span class=\"kw\">if<\/span> <span class=\"kw\">not<\/span> grid:\n        <span class=\"kw\">return<\/span> \n\n    rows, cols = <span class=\"fn\">len<\/span>(grid), <span class=\"fn\">len<\/span>(grid[])\n    count = \n\n    <span class=\"kw\">def<\/span> <span class=\"fn\">bfs<\/span>(r, c):\n        queue = <span class=\"fn\">deque<\/span>([(r, c)])\n        grid[r] = <span class=\"st\">&#039;0&#039;<\/span>  <span class=\"cm\"># Mark as visited<\/span>\n        <span class=\"kw\">while<\/span> queue:\n            row, col = queue.<span class=\"fn\">popleft<\/span>()\n            <span class=\"kw\">for<\/span> dr, dc <span class=\"kw\">in<\/span> [(<span class=\"nm\">1<\/span>,), (-<span class=\"nm\">1<\/span>,), (,<span class=\"nm\">1<\/span>), (,-<span class=\"nm\">1<\/span>)]:\n                nr, nc = row + dr, col + dc\n                <span class=\"kw\">if<\/span>  &lt;= nr &lt; rows <span class=\"kw\">and<\/span>  &lt;= nc &lt; cols <span class=\"kw\">and<\/span> grid[nr][nc] == <span class=\"st\">&#039;1&#039;<\/span>:\n                    grid[nr][nc] = <span class=\"st\">&#039;0&#039;<\/span>\n                    queue.<span class=\"fn\">append<\/span>((nr, nc))\n\n    <span class=\"kw\">for<\/span> r <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(rows):\n        <span class=\"kw\">for<\/span> c <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(cols):\n            <span class=\"kw\">if<\/span> grid[r] == <span class=\"st\">&#039;1&#039;<\/span>:\n                <span class=\"fn\">bfs<\/span>(r, c)\n                count += <span class=\"nm\">1<\/span>\n\n    <span class=\"kw\">return<\/span> count\n\n<span class=\"cm\"># Test<\/span>\ngrid = [\n    [<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>],\n    [<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>],\n    [<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;1&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>],\n    [<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>,<span class=\"st\">&#039;0&#039;<\/span>]\n]\n<span class=\"fn\">print<\/span>(<span class=\"fn\">numIslands<\/span>(grid))\n<span class=\"cm\"># Output: 1<\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>6. Coin Change Problem (Minimum Coins)<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Given coin denominations and a target amount, find the minimum number of coins needed to make the amount. Return -1 if not possible.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff375250\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  coins = [<span class=\"nm\">1<\/span>, <span class=\"nm\">5<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">9<\/span>], amount = <span class=\"nm\">11<\/span>\nOutput: <span class=\"nm\">2<\/span>\nExplanation: <span class=\"nm\">5<\/span> + <span class=\"nm\">6<\/span> = <span class=\"nm\">11<\/span><\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Bottom-up DP. dp[i] = minimum coins to make amount i. For each amount, try all coins and take the minimum.<\/p>\n\n\n\n<div id=\"copy-6a5deff3752a7\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">coinChange<\/span>(coins, amount):\n    dp = [<span class=\"fn\">float<\/span>(<span class=\"st\">&#039;inf&#039;<\/span>)] * (amount + <span class=\"nm\">1<\/span>)\n    dp[] =   <span class=\"cm\"># Base case: 0 coins needed to make amount 0<\/span>\n\n    <span class=\"kw\">for<\/span> i <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(<span class=\"nm\">1<\/span>, amount + <span class=\"nm\">1<\/span>):\n        <span class=\"kw\">for<\/span> coin <span class=\"kw\">in<\/span> coins:\n            <span class=\"kw\">if<\/span> coin &lt;= i:\n                dp[i] = <span class=\"fn\">min<\/span>(dp[i], dp[i - coin] + <span class=\"nm\">1<\/span>)\n\n    <span class=\"kw\">return<\/span> dp[amount] <span class=\"kw\">if<\/span> dp[amount] != <span class=\"fn\">float<\/span>(<span class=\"st\">&#039;inf&#039;<\/span>) <span class=\"kw\">else<\/span> -<span class=\"nm\">1<\/span>\n\n<span class=\"cm\"># Test<\/span>\n<span class=\"fn\">print<\/span>(<span class=\"fn\">coinChange<\/span>([<span class=\"nm\">1<\/span>, <span class=\"nm\">5<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">9<\/span>], <span class=\"nm\">11<\/span>))\n<span class=\"cm\"># Output: 2  (5 + 6 = 11)<\/span>\n\n<span class=\"fn\">print<\/span>(<span class=\"fn\">coinChange<\/span>([<span class=\"nm\">2<\/span>], <span class=\"nm\">3<\/span>))\n<span class=\"cm\"># Output: -1  (not possible)<\/span><\/code><\/pre><\/div>\n\n\n\n<p>Master the Logic: To consistently hit the SP threshold, enroll in the free <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/competitive-programming-course\">Competitive Programming Course by Great Learning Academy<\/a>. This course systematically teaches you how to optimize your code to meet strict time complexity constraints, a crucial skill for medium-to-hard assessment questions.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"hard-level-coding-questions\"><strong>Hard Level Coding Questions<\/strong><\/h2>\n\n\n\n<p><strong>7. Maximize Total Value by Packing Gifts into K Boxes (DP + Sliding Window)<\/strong><\/p>\n\n\n\n<p>This is a representative hard-level problem that has appeared in Infosys specialist programmer coding questions.<\/p>\n\n\n\n<p><em>Problem:<\/em> You have N gifts of different types. Pack them into exactly K boxes (consecutive subarrays) such that each box's value equals the number of distinct gift types in it. Maximize total value.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff3752cb\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  N=<span class=\"nm\">6<\/span>, K=<span class=\"nm\">3<\/span>, gifts=[<span class=\"nm\">1<\/span>,<span class=\"nm\">1<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">3<\/span>,<span class=\"nm\">3<\/span>]\nOutput: <span class=\"nm\">4<\/span>\nExplanation: [<span class=\"nm\">1<\/span>]=<span class=\"nm\">1<\/span>, [<span class=\"nm\">1<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">2<\/span>]=<span class=\"nm\">2<\/span>, [<span class=\"nm\">3<\/span>,<span class=\"nm\">3<\/span>]=<span class=\"nm\">1<\/span> \u2192 total = <span class=\"nm\">4<\/span><\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> DP with a sliding window and a HashMap to track distinct elements. dp[i][j] = maximum value of packing the first j gifts into i boxes. Use a two-pointer or sliding window within each DP transition.<\/p>\n\n\n\n<div id=\"copy-6a5deff37532a\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">maximizeGifts<\/span>(N, K, gifts):\n    <span class=\"cm\"># dp[i][j] = max value packing first j gifts into i boxes<\/span>\n    dp = [[-<span class=\"fn\">float<\/span>(<span class=\"st\">&#039;inf&#039;<\/span>)] * (N + <span class=\"nm\">1<\/span>) <span class=\"kw\">for<\/span> _ <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(K + <span class=\"nm\">1<\/span>)]\n    dp[][] = \n\n    <span class=\"kw\">for<\/span> i <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(<span class=\"nm\">1<\/span>, K + <span class=\"nm\">1<\/span>):\n        <span class=\"kw\">for<\/span> j <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(i, N + <span class=\"nm\">1<\/span>):\n            freq = {}\n            distinct = \n            <span class=\"cm\"># Try all starting positions for the i-th box ending at j<\/span>\n            <span class=\"kw\">for<\/span> start <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(j, i - <span class=\"nm\">1<\/span>, -<span class=\"nm\">1<\/span>):\n                gift = gifts[start - <span class=\"nm\">1<\/span>]\n                freq[gift] = freq.<span class=\"fn\">get<\/span>(gift, ) + <span class=\"nm\">1<\/span>\n                <span class=\"kw\">if<\/span> freq[gift] == <span class=\"nm\">1<\/span>:\n                    distinct += <span class=\"nm\">1<\/span>\n                <span class=\"kw\">if<\/span> dp[i - <span class=\"nm\">1<\/span>][start - <span class=\"nm\">1<\/span>] != -<span class=\"fn\">float<\/span>(<span class=\"st\">&#039;inf&#039;<\/span>):\n                    dp[i][j] = <span class=\"fn\">max<\/span>(dp[i][j], dp[i - <span class=\"nm\">1<\/span>][start - <span class=\"nm\">1<\/span>] + distinct)\n\n    <span class=\"kw\">return<\/span> <span class=\"fn\">max<\/span>(dp[K])\n\n<span class=\"cm\"># Test<\/span>\n<span class=\"fn\">print<\/span>(<span class=\"fn\">maximizeGifts<\/span>(<span class=\"nm\">6<\/span>, <span class=\"nm\">3<\/span>, [<span class=\"nm\">1<\/span>, <span class=\"nm\">1<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">3<\/span>, <span class=\"nm\">3<\/span>]))\n<span class=\"cm\"># Output: 4  ([1]=1, [1,2,2]=2, [3,3]=1 \u2192 total=4)<\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>8. Trapping Rain Water<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Given an elevation map represented by an array, compute how much water it can trap after raining.<\/p>\n\n\n\n<p><em>Example:<\/em><\/p>\n\n\n\n<div id=\"copy-6a5deff37535f\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code>Input:  [,<span class=\"nm\">1<\/span>,,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>,,<span class=\"nm\">1<\/span>,<span class=\"nm\">3<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>]\nOutput: <span class=\"nm\">6<\/span><\/code><\/pre><\/div>\n\n\n\n<p><em>Approach:<\/em> Two-pointer technique. Maintain left_max and right_max. At each position, water trapped = min(left_max, right_max) - height[i].<\/p>\n\n\n\n<div id=\"copy-6a5deff3753ba\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">trap<\/span>(height):\n    <span class=\"kw\">if<\/span> <span class=\"kw\">not<\/span> height:\n        <span class=\"kw\">return<\/span> \n\n    left, right = , <span class=\"fn\">len<\/span>(height) - <span class=\"nm\">1<\/span>\n    left_max, right_max = , \n    water = \n\n    <span class=\"kw\">while<\/span> left &lt; right:\n        <span class=\"kw\">if<\/span> height[left] &lt; height[right]:\n            <span class=\"kw\">if<\/span> height[left] &gt;= left_max:\n                left_max = height[left]\n            <span class=\"kw\">else<\/span>:\n                water += left_max - height[left]\n            left += <span class=\"nm\">1<\/span>\n        <span class=\"kw\">else<\/span>:\n            <span class=\"kw\">if<\/span> height[right] &gt;= right_max:\n                right_max = height[right]\n            <span class=\"kw\">else<\/span>:\n                water += right_max - height[right]\n            right -= <span class=\"nm\">1<\/span>\n\n    <span class=\"kw\">return<\/span> water\n\n<span class=\"cm\"># Test<\/span>\n<span class=\"fn\">print<\/span>(<span class=\"fn\">trap<\/span>([,<span class=\"nm\">1<\/span>,,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>,,<span class=\"nm\">1<\/span>,<span class=\"nm\">3<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">1<\/span>]))\n<span class=\"cm\"># Output: 6<\/span>\n\n<span class=\"fn\">print<\/span>(<span class=\"fn\">trap<\/span>([<span class=\"nm\">4<\/span>,<span class=\"nm\">2<\/span>,,<span class=\"nm\">3<\/span>,<span class=\"nm\">2<\/span>,<span class=\"nm\">5<\/span>]))\n<span class=\"cm\"># Output: 9<\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>9. Longest Increasing Path in a Matrix (DFS + Memoization)<\/strong><\/p>\n\n\n\n<p><em>Problem:<\/em> Given an m x n integer matrix, return the length of the longest increasing path.<\/p>\n\n\n\n<p><em>Approach:<\/em> DFS from each cell with memoization. From each cell, try all 4 directions and move only if the next value is strictly greater.<\/p>\n\n\n\n<div id=\"copy-6a5deff37543b\" class=\"copy-code-wrapper\"><div class=\"copy-code-header\"><span class=\"copy-code-lang\">python<\/span><button type=\"button\" class=\"copy-button\" aria-label=\"Copy code\"><svg class=\"icon-copy\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1Z\"\/><path d=\"M20 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H20C21.1 23 22 22.1 22 21V7C22 5.9 21.1 5 20 5ZM20 21H8V7H20V21Z\"\/><\/svg><svg class=\"icon-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\"\/><\/svg><span class=\"btn-label\">Copy<\/span><\/button><\/div><pre><code><span class=\"kw\">def<\/span> <span class=\"fn\">longestIncreasingPath<\/span>(matrix):\n    <span class=\"kw\">if<\/span> <span class=\"kw\">not<\/span> matrix <span class=\"kw\">or<\/span> <span class=\"kw\">not<\/span> matrix[]:\n        <span class=\"kw\">return<\/span> \n\n    rows, cols = <span class=\"fn\">len<\/span>(matrix), <span class=\"fn\">len<\/span>(matrix[])\n    memo = {}\n\n    <span class=\"kw\">def<\/span> <span class=\"fn\">dfs<\/span>(r, c):\n        <span class=\"kw\">if<\/span> (r, c) <span class=\"kw\">in<\/span> memo:\n            <span class=\"kw\">return<\/span> memo[(r, c)]\n\n        best = <span class=\"nm\">1<\/span>  <span class=\"cm\"># At minimum, the cell itself is a path of length 1<\/span>\n        <span class=\"kw\">for<\/span> dr, dc <span class=\"kw\">in<\/span> [(<span class=\"nm\">1<\/span>,), (-<span class=\"nm\">1<\/span>,), (,<span class=\"nm\">1<\/span>), (,-<span class=\"nm\">1<\/span>)]:\n            nr, nc = r + dr, c + dc\n            <span class=\"kw\">if<\/span>  &lt;= nr &lt; rows <span class=\"kw\">and<\/span>  &lt;= nc &lt; cols <span class=\"kw\">and<\/span> matrix[nr][nc] &gt; matrix[r]:\n                best = <span class=\"fn\">max<\/span>(best, <span class=\"nm\">1<\/span> + <span class=\"fn\">dfs<\/span>(nr, nc))\n\n        memo[(r, c)] = best\n        <span class=\"kw\">return<\/span> best\n\n    <span class=\"kw\">return<\/span> <span class=\"fn\">max<\/span>(<span class=\"fn\">dfs<\/span>(r, c) <span class=\"kw\">for<\/span> r <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(rows) <span class=\"kw\">for<\/span> c <span class=\"kw\">in<\/span> <span class=\"fn\">range<\/span>(cols))\n\n<span class=\"cm\"># Test<\/span>\nmatrix1 = [\n    [<span class=\"nm\">9<\/span>, <span class=\"nm\">9<\/span>, <span class=\"nm\">4<\/span>],\n    [<span class=\"nm\">6<\/span>, <span class=\"nm\">6<\/span>, <span class=\"nm\">8<\/span>],\n    [<span class=\"nm\">2<\/span>, <span class=\"nm\">1<\/span>, <span class=\"nm\">1<\/span>]\n]\n<span class=\"fn\">print<\/span>(<span class=\"fn\">longestIncreasingPath<\/span>(matrix1))\n<span class=\"cm\"># Output: 4  (path: 1 \u2192 2 \u2192 6 \u2192 9)<\/span>\n\nmatrix2 = [\n    [<span class=\"nm\">3<\/span>, <span class=\"nm\">4<\/span>, <span class=\"nm\">5<\/span>],\n    [<span class=\"nm\">3<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">6<\/span>],\n    [<span class=\"nm\">2<\/span>, <span class=\"nm\">2<\/span>, <span class=\"nm\">1<\/span>]\n]\n<span class=\"fn\">print<\/span>(<span class=\"fn\">longestIncreasingPath<\/span>(matrix2))\n<span class=\"cm\"># Output: 4  (path: 3 \u2192 4 \u2192 5 \u2192 6)<\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Success in the Infosys SP and DSE coding rounds comes down to consistent practice, a strong understanding of data structures and algorithms, and the ability to solve problems efficiently under time constraints.&nbsp;<\/p>\n\n\n\n<p>By working through the coding questions and approaches covered in this guide, you'll build the confidence and problem-solving skills needed to perform well in the assessment.&nbsp;<\/p>\n\n\n\n<p>Remember to focus not only on finding the correct solution but also on writing optimized, clean code and analyzing its time and space complexity.<\/p>\n\n\n\n<p>To complete your preparation, don't miss our <a href=\"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-interview-guide-2026\/\"><strong>Infosys SP and DSE Interview Guide 2026<\/strong><\/a>, which covers everything you need to know about the selection process, interview rounds, eligibility, and expert preparation tips.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions-faqs\"><strong>Frequently Asked Questions (FAQs)<\/strong><\/h2>\n\n\n\n<p><strong>1. What coding questions are asked in the Infosys SP and DSE interview?<\/strong><\/p>\n\n\n\n<p>The Infosys SP and DSE coding interviews typically include problems on arrays, strings, linked lists, stacks, queues, trees, graphs, dynamic programming, recursion, greedy algorithms, hashing, and sliding window techniques. The company focuses on evaluating your problem-solving ability, coding efficiency, and understanding of data structures and algorithms.<\/p>\n\n\n\n<p><strong>2. Is the Infosys Specialist Programmer (SP) coding round difficult?<\/strong><\/p>\n\n\n\n<p>Yes, the Infosys Specialist Programmer (SP) coding round is considered more challenging than the standard recruitment process. Candidates are expected to solve medium- to hard-level coding problems within a limited time while writing optimized and error-free code.<\/p>\n\n\n\n<p><strong>3. Which programming language should I use for the Infosys coding interview?<\/strong><\/p>\n\n\n\n<p>Infosys supports multiple programming languages, including C, C++, Java, and Python. You should choose the language you are most comfortable with, as familiarity allows you to solve problems more efficiently and avoid syntax-related mistakes during the assessment.<\/p>\n\n\n\n<p><strong>4. What topics should I prepare for the Infosys DSE coding test?<\/strong><\/p>\n\n\n\n<p>To perform well in the Infosys DSE coding test, you should thoroughly prepare data structures and algorithms, particularly arrays, strings, linked lists, trees, graphs, dynamic programming, recursion, greedy algorithms, binary search, hashing, and graph traversal techniques such as BFS and DFS. Regular practice on coding platforms can help strengthen these concepts.<\/p>\n\n\n\n<p><strong>5. How many coding questions are asked in the Infosys SP assessment?<\/strong><\/p>\n\n\n\n<p>The number of coding questions may vary by recruitment cycle, but candidates are generally asked to solve two or three coding problems. These questions usually progress from medium to hard difficulty and test both correctness and optimization.<\/p>\n\n\n\n<p><strong>6. Is Dynamic Programming important for Infosys SP interviews?<\/strong><\/p>\n\n\n\n<p>Yes, Dynamic Programming is one of the most important topics for the Infosys Specialist Programmer interview. Questions based on Longest Common Subsequence, Coin Change, Knapsack, Matrix DP, and other optimization problems frequently appear in coding assessments.<\/p>\n\n\n\n<p><strong>7. How can I crack the Infosys SP and DSE coding round?<\/strong><\/p>\n\n\n\n<p>The best way to crack the Infosys SP and DSE coding round is to practice coding questions consistently, master core DSA concepts, solve previous-year interview problems, participate in timed coding contests, and learn common interview patterns. Along with coding practice, reviewing your solutions for time and space complexity is equally important.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prepare for the Infosys SP and DSE coding rounds with the most frequently asked coding questions, detailed solutions, and expert preparation tips to ace your interview.<\/p>\n","protected":false},"author":41,"featured_media":118906,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17946,25860],"tags":[],"content_type":[],"class_list":["post-118905","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-career","category-software"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Top Infosys SP and DSE Coding Questions With Answers (2026)<\/title>\n<meta name=\"description\" content=\"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Infosys Coding Questions for SP and DSE (With Answers)\" \/>\n<meta property=\"og:description\" content=\"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-13T13:48:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-13T13:48:47+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-1024x536.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"536\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Infosys Coding Questions for SP and DSE (With Answers)\",\"datePublished\":\"2026-07-13T13:48:45+00:00\",\"dateModified\":\"2026-07-13T13:48:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/\"},\"wordCount\":2109,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/image-22.png\",\"articleSection\":[\"Career Development\",\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/\",\"name\":\"Top Infosys SP and DSE Coding Questions With Answers (2026)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/image-22.png\",\"datePublished\":\"2026-07-13T13:48:45+00:00\",\"dateModified\":\"2026-07-13T13:48:47+00:00\",\"description\":\"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/image-22.png\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/image-22.png\",\"width\":1734,\"height\":907,\"caption\":\"Infosys SP and DSE Coding Questions with Answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/infosys-sp-dse-coding-questions-with-answers-2026\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Career Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/career\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Infosys Coding Questions for SP and DSE (With Answers)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Top Infosys SP and DSE Coding Questions With Answers (2026)","description":"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/","og_locale":"en_US","og_type":"article","og_title":"Infosys Coding Questions for SP and DSE (With Answers)","og_description":"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2026-07-13T13:48:45+00:00","article_modified_time":"2026-07-13T13:48:47+00:00","og_image":[{"width":1024,"height":536,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-1024x536.png","type":"image\/png"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Infosys Coding Questions for SP and DSE (With Answers)","datePublished":"2026-07-13T13:48:45+00:00","dateModified":"2026-07-13T13:48:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/"},"wordCount":2109,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png","articleSection":["Career Development","IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/","url":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/","name":"Top Infosys SP and DSE Coding Questions With Answers (2026)","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png","datePublished":"2026-07-13T13:48:45+00:00","dateModified":"2026-07-13T13:48:47+00:00","description":"Practice the most asked Infosys SP and DSE coding questions with answers. Prepare arrays, DP, graphs, and DSA concepts to crack the Infosys coding round.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png","width":1734,"height":907,"caption":"Infosys SP and DSE Coding Questions with Answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/infosys-sp-dse-coding-questions-with-answers-2026\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Career Development","item":"https:\/\/www.mygreatlearning.com\/blog\/career\/"},{"@type":"ListItem","position":3,"name":"Infosys Coding Questions for SP and DSE (With Answers)"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png",1734,907,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-150x150.png",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-300x157.png",300,157,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-768x402.png",768,402,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-1024x536.png",1024,536,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-1536x803.png",1536,803,true],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22.png",1734,907,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-640x853.png",640,853,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-96x96.png",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2026\/07\/image-22-150x78.png",150,78,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Prepare for the Infosys SP and DSE coding rounds with the most frequently asked coding questions, detailed solutions, and expert preparation tips to ace your interview.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/118905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=118905"}],"version-history":[{"count":31,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/118905\/revisions"}],"predecessor-version":[{"id":118937,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/118905\/revisions\/118937"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/118906"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=118905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=118905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=118905"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=118905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}