{"id":27205,"date":"2025-05-07T11:15:15","date_gmt":"2025-05-07T05:45:15","guid":{"rendered":"https:\/\/internshala.com\/blog\/?p=27205"},"modified":"2026-03-16T11:05:28","modified_gmt":"2026-03-16T05:35:28","slug":"infosys-power-programmer-coding-questions-and-answers","status":"publish","type":"post","link":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/","title":{"rendered":"Infosys Power Programmer Coding Questions and Answers"},"content":{"rendered":"\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>You know?<\/strong> The Power Programmer unit at Infosys includes over 3,000 elite engineers, representing the top 1% of the company\u2019s global engineering talent.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Infosys, a global leader in IT consulting and digital transformation, offers the \u2018Power Programmer\u2019 role for top coding professionals. This position focuses on full-stack development, problem-solving, and advanced technologies, making it a highly desired opportunity. To secure the role, candidates undergo a rigorous recruitment process, which includes coding tests, technical evaluations, and interviews. This guide covers Infosys Power Programmer coding questions and answers, the recruitment process, common interview questions, and expert tips to help you succeed in securing the job.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Infosys_Power_Programmer_Recruitment_Process\" >Infosys Power Programmer Recruitment Process<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Infosys_Power_Programmer_Coding_Questions_and_Answers_on_Algorithm\" >Infosys Power Programmer Coding Questions and Answers on Algorithm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Infosys_Power_Programmer_Interview_Coding_Questions_and_Answers_on_Data_Structure\" >Infosys Power Programmer Interview Coding Questions and Answers on Data Structure<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Infosys_Power_Programmer_Interview_Coding_Questions_on_String_Manipulation\" >Infosys Power Programmer Interview&nbsp; Coding Questions on String Manipulation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Tips_to_Prepare_for_Infosys_Power_Programmer_Interview\" >Tips to Prepare for Infosys Power Programmer Interview<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#FAQs\" >FAQs<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Power_Programmer_Recruitment_Process\"><\/span>Infosys Power Programmer Recruitment Process<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Infosys follows a comprehensive selection process for its power programmer role. It is designed to identify candidates with strong coding abilities, analytical thinking, and adaptability to cutting-edge technologies. Here is the recruitment process for the power programmer role:<\/p>\n\n\n\n<ol>\n<li><strong>Coding Assessments: <\/strong>Two coding rounds evaluate problem-solving efficiency, algorithmic thinking, and mastery of <a href=\"https:\/\/trainings.internshala.com\/blog\/python-data-structures\/\" target=\"_blank\" rel=\"noreferrer noopener\">data structures<\/a> through real-world programming challenges.<\/li>\n\n\n\n<li><strong>Technical Interviews: <\/strong>It involves in-depth discussions on core programming concepts, system design strategies, and practical application of technologies to assess a candidate\u2019s expertise.<\/li>\n\n\n\n<li><strong>HR Interview: <\/strong>It focuses on a candidate\u2019s communication skills, professionalism, and alignment with Infosys&#8217; values, ensuring cultural and workplace compatibility.<\/li>\n\n\n\n<li><strong>Final Selection: <\/strong>Successful candidates are offered an internship, specialized <a href=\"https:\/\/trainings.internshala.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">training program<\/a>, or direct project placement, depending on their performance and expertise.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large desktop-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-power-programmer-coding-questions&amp;utm_campaign=candidate-web-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg\" alt=\"Find and Apply Banner\" class=\"wp-image-21795\" srcset=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg 1024w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-672x133.jpg 672w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1536x305.jpg 1536w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-2048x406.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full mobile-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-power-programmer-coding-questions&amp;utm_campaign=candidate-mobile-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"256\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Job-Banner-for-candidates.jpg\" alt=\"Job Banner for candidates\" class=\"wp-image-21794\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Power_Programmer_Coding_Questions_and_Answers_on_Algorithm\"><\/span>Infosys Power Programmer Coding Questions and Answers on Algorithm<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This section highlights the most commonly asked Infosys Power Programmer coding questions based on algorithms. These questions assess your problem-solving abilities and understanding of fundamental algorithms. We provide detailed examples and solutions to help you effectively prepare for the coding round.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q1. Write a program to swap two numbers.<\/h3>\n\n\n\n<p><strong>Answer:<\/strong> Here is a <a href=\"https:\/\/trainings.internshala.com\/blog\/what-is-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python<\/a> program to swap two numbers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = int(input(\"Enter the first number: \"))\nb = int(input(\"Enter the second number: \"))\n\nprint(f\"\\nBefore swap:\\na = {a}, b = {b}\")\n\n# Swap using tuple unpacking (no need for a temp variable)\na, b = b, a\n\nprint(f\"After swap (using tuple unpacking):\\na = {a}, b = {b}\\n\")\n\n\/\/ Output\nEnter the first number: 5\nEnter the second number: 10\n\nBefore swap:\na = 5, b = 10\nAfter swap (using tuple unpacking):\na = 10, b = 5\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q2. Write a program to convert a decimal number to a binary number.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a simple Python program to convert a decimal number to a binary number:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def decimal_to_binary(n: int) -&gt; str:\n    \"\"\"Convert decimal to binary without using built-in functions.\"\"\"\n    if n == 0:\n        return \"0\"\n    bits = &#91;]\n    while n &gt; 0:\n        bits.append(str(n % 2))\n        n \/\/= 2\n    return ''.join(reversed(bits))\n\ndef main():\n    num = int(input(\"Enter a non-negative integer: \"))\n    if num &lt; 0:\n        print(\"Please enter a non-negative integer.\")\n        return\n\n    binary = decimal_to_binary(num)\n    print(f\"Binary: {binary}\")\n\nif __name__ == \"__main__\":\n    main()\n\n\/\/ Output\nEnter a non-negative integer: 12\nBinary: 1100\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q3. Given the head of a singly linked list, reverse the list and return the new head.<\/h3>\n\n\n\n<p><strong>Answer:<\/strong> Here is a clean and efficient C++ solution to reverse a singly linked list:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nstruct ListNode {\n    int val;\n    ListNode* next;\n    ListNode(int x) : val(x), next(nullptr) {}\n};\n\nListNode* reverseList(ListNode* head) {\n    ListNode* prev = nullptr;\n    ListNode* curr = head;\n    \n    while (curr) {\n        ListNode* next = curr-&gt;next; \/\/ Store next node\n        curr-&gt;next = prev;           \/\/ Reverse current node's pointer\n        prev = curr;                 \/\/ Move prev one step forward\n        curr = next;                 \/\/ Move curr one step forward\n    }\n    \n    return prev; \/\/ New head of the reversed list\n}\n\nvoid printList(ListNode* head) {\n    ListNode* curr = head;\n    while (curr) {\n        cout &lt;&lt; curr-&gt;val &lt;&lt; \" -&gt; \";\n        curr = curr-&gt;next;\n    }\n    cout &lt;&lt; \"null\" &lt;&lt; endl;\n}\n\nint main() {\n    \/\/ Create a simple linked list: 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; null\n    ListNode* head = new ListNode(1);\n    head-&gt;next = new ListNode(2);\n    head-&gt;next-&gt;next = new ListNode(3);\n    head-&gt;next-&gt;next-&gt;next = new ListNode(4);\n    \n    cout &lt;&lt; \"Original List: \";\n    printList(head);\n\n    ListNode* reversedHead = reverseList(head);\n\n    cout &lt;&lt; \"Reversed List: \";\n    printList(reversedHead);\n\n    return 0;\n}\n\n\/\/Output\nOriginal List: 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; null\nReversed List: 4 -&gt; 3 -&gt; 2 -&gt; 1 -&gt; null\n<\/code><\/pre>\n\n\n\n<p><strong>Pro Tip:<\/strong> Strengthen your programming skills by exploring <a href=\"https:\/\/trainings.internshala.com\/blog\/cpp-interview-questions-and-answers\/\" target=\"_blank\" rel=\"noreferrer noopener\">C++ interview questions and answers<\/a>. Enhance your coding skills and excel in Power Programmer interview questions at Infosys.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q4. Write a program to convert a decimal number to an octal number.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a solution in C++ that manually converts a decimal number to an octal number:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint main() {\n    int num;\n    cout &lt;&lt; \"Enter a decimal number: \";\n    cin &gt;&gt; num;\n\n    \/\/ Special case for zero\n    if (num == 0) {\n        cout &lt;&lt; \"Octal: 0\" &lt;&lt; endl;\n        return 0;\n    }\n\n    vector&lt;int&gt; octalDigits;\n    int n = num;\n\n    \/\/ Convert to octal by repeatedly dividing by 8 and storing remainders\n    while (n &gt; 0) {\n        octalDigits.push_back(n % 8);\n        n \/= 8;\n    }\n\n    \/\/ The digits are collected in reverse order, so reverse them\n    reverse(octalDigits.begin(), octalDigits.end());\n\n    \/\/ Display the octal number\n    cout &lt;&lt; \"Octal: \";\n    for (int digit : octalDigits) {\n        cout &lt;&lt; digit;\n    }\n    cout &lt;&lt; endl;\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q5. Check if a Number is Prime<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Below is a Python function that checks whether a number is prime by testing divisibility from 2 up to \u221an:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def is_prime(n):\n    if n &lt;= 1:\n        return False\n    if n == 2:\n        return True\n    if n % 2 == 0:\n        return False\n    for i in range(3, int(n**0.5) + 1, 2):  # Only check odd numbers\n        if n % i == 0:\n            return False\n    return True\n#Example usage and Output\n# Test cases\nprint(is_prime(2))    # Output: True, since 2 is a prime number\nprint(is_prime(11))   # Output: True, since 11 is a prime number\nprint(is_prime(15))   # Output: False, since 15 is not a prime number\nprint(is_prime(18))   # Output: False, since 18 is not a prime number\nprint(is_prime(29))   # Output: True, since 29 is a prime number\nprint(is_prime(97))   # Output: True, since 97 is a prime number\nprint(is_prime(100))  # Output: False, since 100 is not a prime number\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q6. Given the head of a singly linked list, reverse the list by changing the next pointers of the nodes, and return the new head of the reversed list.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a concise, in-place Python implementation that reverses a singly linked list by updating each node\u2019s next pointer:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class ListNode:\n    def __init__(self, val=0, next=None):\n        self.val = val\n        self.next = next\n\ndef reverse_list(head: ListNode) -&gt; ListNode:\n    prev, curr = None, head\n    while curr:\n        nxt = curr.next      # save next node\n        curr.next = prev     # reverse the link\n        prev, curr = curr, nxt  # advance pointers\n    return prev\n\n# Helper function to print a linked list\ndef print_list(head):\n    while head:\n        print(head.val, end=\" -&gt; \" if head.next else \"\\n\")\n        head = head.next\n\n# Example usage\n# Creating the linked list: 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5\nhead = ListNode(1)\nhead.next = ListNode(2)\nhead.next.next = ListNode(3)\nhead.next.next.next = ListNode(4)\nhead.next.next.next.next = ListNode(5)\n\nprint(\"Original list:\")\nprint_list(head)\n\n# Reverse the linked list\nreversed_head = reverse_list(head)\n\nprint(\"Reversed list:\")\nprint_list(reversed_head)\n\n\/\/Output\nOriginal list:\n1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5\nReversed list:\n5 -&gt; 4 -&gt; 3 -&gt; 2 -&gt; 1\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q7. Given a directed graph with V vertices numbered 0 to V\u22121 and an edge list, determine whether the graph contains a cycle.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a JavaScript program that uses depth-first search with a recursion stack to detect if a directed graph contains a cycle:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function hasCycle(V, edges) {\n    const adj = Array.from({ length: V }, () =&gt; &#91;]);\n    for (const &#91;u, v] of edges) {\n        adj&#91;u].push(v);\n    }\n\n    const visited = new Array(V).fill(false);\n    const inStack = new Array(V).fill(false);\n\n    function dfs(u) {\n        visited&#91;u] = inStack&#91;u] = true;\n        for (const v of adj&#91;u]) {\n            if (!visited&#91;v] &amp;&amp; dfs(v)) return true;\n            if (inStack&#91;v]) return true;\n        }\n        inStack&#91;u] = false;\n        return false;\n    }\n\n    for (let i = 0; i &lt; V; i++) {\n        if (!visited&#91;i] &amp;&amp; dfs(i)) {\n            return true;\n        }\n    }\n    return false;\n}\n\n# Example usage\nconst V1 = 4;\nconst edges1 = &#91;&#91;0, 1], &#91;1, 2], &#91;2, 0], &#91;2, 3]];\nconsole.log(hasCycle(V1, edges1)); \/\/ Output: true (Cycle exists)\n\nconst V2 = 4;\nconst edges2 = &#91;&#91;0, 1], &#91;1, 2], &#91;2, 3]];\nconsole.log(hasCycle(V2, edges2)); \/\/ Output: false (No cycle)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q8. Given two strings s1 and s2, return the length of their longest common subsequence (a subsequence appears in both strings in the same relative order).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Below is a <a href=\"https:\/\/trainings.internshala.com\/blog\/what-is-java\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java<\/a> implementation using a dynamic-programming table to compute the length of the longest common subsequence between two strings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class LCS {\n    public int longestCommonSubsequence(String s1, String s2) {\n        int m = s1.length(), n = s2.length();\n        int&#91;]&#91;] dp = new int&#91;m + 1]&#91;n + 1];\n\n        for (int i = 1; i &lt;= m; i++) {\n            for (int j = 1; j &lt;= n; j++) {\n                if (s1.charAt(i - 1) == s2.charAt(j - 1))\n                    dp&#91;i]&#91;j] = dp&#91;i - 1]&#91;j - 1] + 1;\n                else\n                    dp&#91;i]&#91;j] = Math.max(dp&#91;i - 1]&#91;j], dp&#91;i]&#91;j - 1]);\n            }\n        }\n        return dp&#91;m]&#91;n];\n    }\n\n    public static void main(String&#91;] args) {\n        LCS lcs = new LCS();\n\n        String s1 = \"abcde\";\n        String s2 = \"ace\";\n        int result = lcs.longestCommonSubsequence(s1, s2);\n        System.out.println(\"Length of LCS: \" + result);\n    }\n}\n\n\/\/Output\nLength of LCS: 3\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q9. Given an array heights[] representing bar heights in a histogram, find the area of the largest rectangle that can be formed.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a Python program, in which we use a stack to keep track of the indices of the bars. We iterate through each bar and calculate the area, considering the current bar as the smallest bar in the rectangle.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def largestRectangleArea(heights):\n    stack = &#91;]\n    max_area = 0\n    heights.append(0)  # Append a zero to pop all remaining bars in stack\n\n    for i, h in enumerate(heights):\n        while stack and heights&#91;stack&#91;-1]] &gt; h:\n            height = heights&#91;stack.pop()]\n            width = i if not stack else i - stack&#91;-1] - 1\n            max_area = max(max_area, height * width)\n        stack.append(i)\n\n    return max_area\n\n# Example usage\nheights = &#91;2, 1, 5, 6, 2, 3]\nresult = largestRectangleArea(heights)\nprint(\"Largest Rectangle Area:\", result)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q10. Given an array of distinct integers arr[], return the minimum number of swaps needed to sort it in ascending order.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a solution in a JavaScript program with minimum number of swaps needed to sort the array in ascending order:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function minSwaps(arr) {\n    const n = arr.length;\n    const pairs = arr.map((v, i) =&gt; &#91;v, i]).sort((a, b) =&gt; a&#91;0] - b&#91;0]);\n    const visited = Array(n).fill(false);\n    let swaps = 0;\n\n    for (let i = 0; i &lt; n; i++) {\n        if (visited&#91;i] || pairs&#91;i]&#91;1] === i) continue;\n        let cycleSize = 0, j = i;\n        while (!visited&#91;j]) {\n            visited&#91;j] = true;\n            j = pairs&#91;j]&#91;1];\n            cycleSize++;\n        }\n        swaps += cycleSize - 1;\n    }\n    return swaps;\n}\n\n\/\/ Example usage\nconst arr = &#91;4, 3, 2, 1];\nconst result = minSwaps(arr);\nconsole.log(\"Minimum number of swaps:\", result);\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q11. Write a function that takes a string and returns the string in reverse order.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a JavaScript function that reverses a given string by splitting it into an array of characters, reversing the array, and then joining it back into a string:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function reverseString(str) {\n  return str.split('').reverse().join('');\n}\n\n# Example usage\nconsole.log(reverseString(\"hello\")); \/\/ Output: \"olleh\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q12. Write a function that returns the factorial of a non-negative integer n (i.e., n!).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a C++ function that returns the factorial of a non-negative integer n (i.e., n!):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int factorial(int n) {\n    if (n &lt; 0)\n        throw std::invalid_argument(\"Input must be a non-negative integer\");\n    if (n &lt;= 1)\n        return 1;\n    return n * factorial(n - 1);\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q13. Write a function that takes a string s and returns true if it reads the same forwards and backwards, otherwise false.&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Below is a JavaScript approach that checks if a string is a palindrome by reversing it and comparing it to the original:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function isPalindrome(s) {\n  const reversed = s.split('').reverse().join('');\n  return s === reversed;\n}\n\n\/\/ Example usage\nconsole.log(isPalindrome(\"racecar\")); \/\/ Output: true\nconsole.log(isPalindrome(\"hello\"));   \/\/ Output: false\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q14. Write a function that takes a list of integers arr and returns the maximum element.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python approach that finds the maximum element in a list by iterating through the list and updating the maximum value encountered so far:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fdef find_max(arr):\n    return max(arr)\n\n# Example usage\nprint(find_max(&#91;3, 7, 2, 9, 5]))  # Output: 9\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q15. Write a function that takes an integer n and returns true if it\u2019s even and false otherwise.&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python approach that finds the maximum element in a list by iterating through the list and updating the maximum value encountered so far:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def is_even(n):\n    return n % 2 == 0\n\n# Example usage\nprint(is_even(4))  # Output: True\nprint(is_even(7))  # Output: False\n<\/code><\/pre>\n\n\n\n<p><strong>Pro Tip: <\/strong>Boost your algorithm-based interview prep by checking out our <a href=\"https:\/\/internshala.com\/blog\/infosys-coding-interview-questions-and-answers\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys coding interview questions and answers<\/a> blog. Strengthen problem-solving skills and excel in the Power Programmer interview at Infosys.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Power_Programmer_Interview_Coding_Questions_and_Answers_on_Data_Structure\"><\/span>Infosys Power Programmer Interview Coding Questions and Answers on Data Structure<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this section, we explore the most commonly asked Infosys Power Programmer coding questions focused on data structures. These questions are designed to assess your understanding of fundamental data structures, including arrays, linked lists, trees, graphs, and hash tables. By reviewing these key concepts and practicing the corresponding problems, you can strengthen your ability to tackle data structure-related challenges during the interview process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q16. How do you reverse a singly linked list in-place?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Below is an in-place Python solution to reverse a singly linked list by updating the following pointers of each node:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class ListNode:\n    def __init__(self, val=0, next=None):\n        self.val  = val\n        self.next = next\n\ndef reverseList(head: ListNode) -&gt; ListNode:\n    prev = None\n    curr = head\n    while curr:\n        # 1. Remember the next node\n        next_node = curr.next\n        \n        # 2. Reverse the pointer on the current node\n        curr.next = prev\n        \n        # 3. Advance prev and curr one step forward\n        prev = curr\n        curr = next_node\n\n    # At the end, prev points to the new head of the reversed list\n    return prev\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q17. How do you detect a cycle in a singly linked list?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a JavaScript function that detects a cycle in a singly linked list using Floyd\u2019s Cycle Detection Algorithm:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function detectCycle(head) {\n    if (!head || !head.next) {\n        return false; \/\/ No cycle if the list is empty or has only one element\n    }\n\n    let slow = head; \/\/ Tortoise\n    let fast = head; \/\/ Hare\n\n    while (fast !== null &amp;&amp; fast.next !== null) {\n        slow = slow.next;         \/\/ Move slow by 1 step\n        fast = fast.next.next;    \/\/ Move fast by 2 steps\n\n        if (slow === fast) {\n            return true; \/\/ Cycle detected\n        }\n    }\n\n    return false; \/\/ No cycle found\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q18. How do you implement a queue using two stacks?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a C++ implementation of a queue using two stacks. The enqueue operation transfers elements between stacks to maintain the correct order, while dequeue simply pops from the main stack:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;stack&gt;\nusing namespace std;\n\nclass QueueUsingTwoStacks {\nprivate:\n    stack&lt;int&gt; stack1, stack2;\n\npublic:\n    \/\/ Enqueue operation: push to stack1\n    void enqueue(int x) {\n        stack1.push(x);\n    }\n\n    \/\/ Dequeue operation: transfer elements from stack1 to stack2, then pop from stack2\n    int dequeue() {\n        if (stack2.empty()) {\n            \/\/ Transfer elements from stack1 to stack2 if stack2 is empty\n            while (!stack1.empty()) {\n                stack2.push(stack1.top());\n                stack1.pop();\n            }\n        }\n\n        if (stack2.empty()) {\n            cout &lt;&lt; \"Queue is empty!\" &lt;&lt; endl;\n            return -1; \/\/ Return an error code\n        }\n\n        int front = stack2.top();\n        stack2.pop();\n        return front;\n    }\n\n    \/\/ Check if the queue is empty\n    bool isEmpty() {\n        return stack1.empty() &amp;&amp; stack2.empty();\n    }\n};\n\nint main() {\n    QueueUsingTwoStacks q;\n    q.enqueue(10);\n    q.enqueue(20);\n    q.enqueue(30);\n\n    cout &lt;&lt; \"Dequeued: \" &lt;&lt; q.dequeue() &lt;&lt; endl; \/\/ 10\n    cout &lt;&lt; \"Dequeued: \" &lt;&lt; q.dequeue() &lt;&lt; endl; \/\/ 20\n    cout &lt;&lt; \"Dequeued: \" &lt;&lt; q.dequeue() &lt;&lt; endl; \/\/ 30\n\n    cout &lt;&lt; \"Dequeued: \" &lt;&lt; q.dequeue() &lt;&lt; endl; \/\/ Queue is empty!\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q19. How do you convert an infix expression to postfix notation?<\/h3>\n\n\n\n<p><strong>Answer:<\/strong> Below is a Python implementation that converts an infix expression to postfix (Reverse Polish Notation) using a stack to manage operator precedence and parentheses:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def precedence(op):\n    if op == '+' or op == '-':\n        return 1\n    if op == '*' or op == '\/':\n        return 2\n    return 0\n\ndef infixToPostfix(expression):\n    stack = &#91;]  # To store operators and parentheses\n    output = &#91;]  # To store the final postfix expression\n    \n    for char in expression:\n        # If the character is an operand (number or variable), add it to the output\n        if char.isalnum():  # This checks if the character is an operand (number or variable)\n            output.append(char)\n        \n        # If the character is '(', push it to the stack\n        elif char == '(':\n            stack.append(char)\n        \n        # If the character is ')', pop from the stack to the output until '(' is found\n        elif char == ')':\n            while stack and stack&#91;-1] != '(':\n                output.append(stack.pop())\n            stack.pop()  # Pop the '(' from the stack\n        \n        # If the character is an operator, pop operators from the stack to the output\n        # based on precedence, then push the current operator to the stack\n        elif char in '+-*\/':\n            while stack and precedence(stack&#91;-1]) &gt;= precedence(char):\n                output.append(stack.pop())\n            stack.append(char)\n    \n    # Pop all the remaining operators from the stack to the output\n    while stack:\n        output.append(stack.pop())\n    \n    return ''.join(output)\n\n# Example usage\nexpression = \"A+(B*C-(D\/E^F)*G)*H\"\nprint(\"Infix Expression: \", expression)\nprint(\"Postfix Expression: \", infixToPostfix(expression))\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q20. How do you perform a level-order traversal (breadth-first) of a binary tree?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a JavaScript implementation of level order traversal (breadth-first traversal) of a binary tree using a queue to process nodes level by level:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function levelOrder(root) {\n    const res = &#91;];\n    if (!root) return res;\n\n    const q = &#91;root]; \/\/ Initialize the queue with the root node\n    while (q.length) {\n        const level = &#91;]; \/\/ Array to store the nodes at the current level\n        const size = q.length; \/\/ Number of nodes at the current level\n\n        for (let i = 0; i &lt; size; i++) {\n            const node = q.shift(); \/\/ Dequeue the front node from the queue\n            level.push(node.val);   \/\/ Add the node's value to the level array\n\n            if (node.left)  q.push(node.left);  \/\/ Enqueue left child if exists\n            if (node.right) q.push(node.right); \/\/ Enqueue right child if exists\n        }\n\n        res.push(level); \/\/ Add the current level's nodes to the result\n    }\n\n    return res; \/\/ Return the result after all levels are processed\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q21. How do you implement a Trie (prefix tree) with insert and search operations?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a C++ implementation of a Trie (prefix tree) that supports insert, search, and starts with operations using an array of child pointers for each lowercase English letter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>struct TrieNode {\n    bool isEnd;\n    TrieNode* children&#91;26];\n\n    TrieNode() : isEnd(false) {\n        for (auto &amp;c : children) c = nullptr;\n    }\n};\n\nclass Trie {\nprivate:\n    TrieNode* root;\n\npublic:\n    Trie() {\n        root = new TrieNode();\n    }\n\n    \/\/ Inserts a word into the Trie\n    void insert(const string &amp;word) {\n        TrieNode* node = root;\n        for (char c : word) {\n            int idx = c - 'a';\n            if (!node-&gt;children&#91;idx]) \n                node-&gt;children&#91;idx] = new TrieNode();\n            node = node-&gt;children&#91;idx];\n        }\n        node-&gt;isEnd = true;\n    }\n\n    \/\/ Searches for a word in the Trie\n    bool search(const string &amp;word) {\n        TrieNode* node = root;\n        for (char c : word) {\n            int idx = c - 'a';\n            if (!node-&gt;children&#91;idx]) return false;\n            node = node-&gt;children&#91;idx];\n        }\n        return node-&gt;isEnd;\n    }\n\n    \/\/ Checks if any word in the Trie starts with the given prefix\n    bool startsWith(const string &amp;prefix) {\n        TrieNode* node = root;\n        for (char c : prefix) {\n            int idx = c - 'a';\n            if (!node-&gt;children&#91;idx]) return false;\n            node = node-&gt;children&#91;idx];\n        }\n        return true;\n    }\n};\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q22. How do you find the top K frequent elements in an array?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python solution to find the top K most frequent elements in an array using a counter and a max-heap (via heapq.nlargest):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from collections import Counter\nimport heapq\n\ndef topKFrequent(nums, k):\n    # Count the frequency of each element in the array\n    count = Counter(nums)\n    \n    # Use heapq.nlargest to find the K most frequent elements\n    # The key argument ensures we are sorting by frequency (the second element of the tuple)\n    return &#91;item&#91;0] for item in heapq.nlargest(k, count.items(), key=lambda x: x&#91;1])]\n\n# Example usage:\nnums = &#91;1,1,1,2,2,3]\nk = 2\nprint(topKFrequent(nums, k))  # Output: &#91;1, 2]\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q23. How do you design a HashMap without using built-in libraries?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a JavaScript implementation of a basic HashMap without using any built-in Map or Set libraries. It uses an array of buckets and simple modular hashing to store key-value pairs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class MyHashMap {\n    constructor() {\n        this.SIZE = 1000;\n        this.data = Array.from({ length: this.SIZE }, () =&gt; &#91;]);\n    }\n\n    \/\/ Hash function to map the key to an index\n    _hash(key) {\n        return key % this.SIZE;\n    }\n\n    \/\/ Put a key-value pair into the map\n    put(key, value) {\n        const h = this._hash(key);\n        for (const pair of this.data&#91;h]) {\n            if (pair&#91;0] === key) {\n                pair&#91;1] = value;\n                return;\n            }\n        }\n        this.data&#91;h].push(&#91;key, value]);\n    }\n\n    \/\/ Get the value for a given key\n    get(key) {\n        const h = this._hash(key);\n        for (const &#91;k, v] of this.data&#91;h]) {\n            if (k === key) return v;\n        }\n        return -1;  \/\/ Return -1 if the key is not found\n    }\n\n    \/\/ Remove a key-value pair from the map\n    remove(key) {\n        const h = this._hash(key);\n        for (let i = 0; i &lt; this.data&#91;h].length; i++) {\n            if (this.data&#91;h]&#91;i]&#91;0] === key) {\n                this.data&#91;h].splice(i, 1);\n                return;\n            }\n        }\n    }\n}\n\n\/\/ Example usage:\nconst map = new MyHashMap();\nmap.put(1, \"one\");\nmap.put(2, \"two\");\nmap.put(1001, \"one thousand one\");\n\nconsole.log(map.get(1));  \/\/ Output: \"one\"\nconsole.log(map.get(2));  \/\/ Output: \"two\"\nconsole.log(map.get(1001));  \/\/ Output: \"one thousand one\"\nconsole.log(map.get(3));  \/\/ Output: -1 (key not found)\n\nmap.remove(2);\nconsole.log(map.get(2));  \/\/ Output: -1 (key removed)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q24.&nbsp; How do you check if the parentheses in a string are balanced?<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a C++ function that checks whether the parentheses in a string are balanced using a stack:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;stack&gt;\n#include &lt;string&gt;\n\nbool areParenthesesBalanced(const std::string&amp; expression) {\n    std::stack&lt;char&gt; s;\n\n    for (char ch : expression) {\n        if (ch == '(') {\n            s.push(ch); \/\/ Push opening parenthesis onto stack\n        } else if (ch == ')') {\n            if (s.empty()) return false; \/\/ Stack is empty, no matching opening parenthesis\n            s.pop(); \/\/ Pop the matching opening parenthesis\n        }\n    }\n\n    return s.empty(); \/\/ If stack is empty, parentheses are balanced\n}\n\nint main() {\n    std::cout &lt;&lt; (areParenthesesBalanced(\"(())\") ? \"Balanced\" : \"Unbalanced\") &lt;&lt; std::endl; \/\/ Balanced\n    std::cout &lt;&lt; (areParenthesesBalanced(\"(()\") ? \"Balanced\" : \"Unbalanced\") &lt;&lt; std::endl;  \/\/ Unbalanced\n    std::cout &lt;&lt; (areParenthesesBalanced(\"())(\") ? \"Balanced\" : \"Unbalanced\") &lt;&lt; std::endl; \/\/ Unbalanced\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q25. Find the middle element of a singly linked list.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a simple C++ function that finds the middle element of a singly linked list. The approach uses the two-pointer technique (also known as the slow and fast pointer approach) to find the middle element in one pass.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\n\/\/ Define the structure for the node\nstruct Node {\n    int data;\n    Node* next;\n    Node(int x) : data(x), next(NULL) {}\n};\n\n\/\/ Function to find the middle element of the linked list\nNode* findMiddle(Node* head) {\n    if (head == NULL) return NULL;\n\n    Node* slow = head;  \/\/ Slow pointer\n    Node* fast = head;  \/\/ Fast pointer\n\n    \/\/ Move fast pointer by two steps and slow pointer by one step\n    while (fast != NULL &amp;&amp; fast-&gt;next != NULL) {\n        slow = slow-&gt;next;      \/\/ Move slow pointer one step\n        fast = fast-&gt;next-&gt;next; \/\/ Move fast pointer two steps\n    }\n\n    return slow; \/\/ Slow pointer is now at the middle element\n}\n\n\/\/ Function to insert a new node at the end of the list\nvoid insert(Node*&amp; head, int data) {\n    Node* newNode = new Node(data);\n    if (head == NULL) {\n        head = newNode;\n        return;\n    }\n    Node* temp = head;\n    while (temp-&gt;next != NULL) {\n        temp = temp-&gt;next;\n    }\n    temp-&gt;next = newNode;\n}\n\n\/\/ Function to print the linked list\nvoid printList(Node* head) {\n    while (head != NULL) {\n        cout &lt;&lt; head-&gt;data &lt;&lt; \" -&gt; \";\n        head = head-&gt;next;\n    }\n    cout &lt;&lt; \"NULL\" &lt;&lt; endl;\n}\n\nint main() {\n    Node* head = NULL;\n\n    \/\/ Insert some values into the linked list\n    insert(head, 1);\n    insert(head, 2);\n    insert(head, 3);\n    insert(head, 4);\n    insert(head, 5);\n\n    \/\/ Print the linked list\n    cout &lt;&lt; \"Linked List: \";\n    printList(head);\n\n    \/\/ Find and print the middle element\n    Node* middle = findMiddle(head);\n    if (middle != NULL) {\n        cout &lt;&lt; \"Middle element: \" &lt;&lt; middle-&gt;data &lt;&lt; endl;\n    } else {\n        cout &lt;&lt; \"List is empty.\" &lt;&lt; endl;\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q26. Merge two sorted linked lists.<\/h3>\n\n\n\n<p><strong>Answer. <\/strong>Here is a JavaScript function that merges two sorted linked lists into one sorted list by comparing node values iteratively:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function mergeTwoLists(l1, l2) {\n    let dummy = new ListNode(0), tail = dummy;\n    while (l1 &amp;&amp; l2) {\n        if (l1.val &lt; l2.val) { \n            tail.next = l1; \n            l1 = l1.next; \n        } else { \n            tail.next = l2; \n            l2 = l2.next; \n        }\n        tail = tail.next;\n    }\n    tail.next = l1 || l2;\n    return dummy.next;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q27. Design a stack that supports getMin() in O(1) time.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the design of a stack that supports&nbsp; getMin() in O(1) time, in a Python program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class MinStack:\n    def __init__(self):\n        self.stack = &#91;]  # main stack to store elements\n        self.min_stack = &#91;]  # auxiliary stack to store minimum elements\n\n    def push(self, x: int) -&gt; None:\n        # Push the element onto the main stack\n        self.stack.append(x)\n        \n        # Push the minimum element onto the min_stack\n        if not self.min_stack or x &lt;= self.min_stack&#91;-1]:\n            self.min_stack.append(x)\n\n    def pop(self) -&gt; None:\n        # Pop the top element from the main stack\n        if self.stack:\n            popped_value = self.stack.pop()\n            # If the popped element is the same as the top of the min_stack, pop it from min_stack as well\n            if popped_value == self.min_stack&#91;-1]:\n                self.min_stack.pop()\n\n    def top(self) -&gt; int:\n        # Return the top element of the main stack\n        if self.stack:\n            return self.stack&#91;-1]\n\n    def getMin(self) -&gt; int:\n        # Return the top element of the min_stack, which is the minimum element in the stack\n        if self.min_stack:\n            return self.min_stack&#91;-1]\n\n# Example Usage\nmin_stack = MinStack()\nmin_stack.push(5)\nmin_stack.push(3)\nmin_stack.push(8)\nprint(min_stack.getMin())  # Output: 3\nmin_stack.pop()\nprint(min_stack.getMin())  # Output: 3\nmin_stack.pop()\nprint(min_stack.getMin())  # Output: 5\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q28. Perform a binary search on a sorted array.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a C++ function that performs binary search on a sorted array to find the index of a target element:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint binarySearch(vector&lt;int&gt;&amp; a, int target) {\n    int lo = 0, hi = a.size() - 1;\n    while (lo &lt;= hi) {\n        int mid = lo + (hi - lo) \/ 2;\n        if (a&#91;mid] == target) return mid;\n        else if (a&#91;mid] &lt; target) lo = mid + 1;\n        else hi = mid - 1;\n    }\n    return -1;\n}\n\nint main() {\n    vector&lt;int&gt; arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\n    int target = 7;\n    int index = binarySearch(arr, target);\n    if (index != -1) {\n        cout &lt;&lt; \"Target found at index: \" &lt;&lt; index &lt;&lt; endl;\n    } else {\n        cout &lt;&lt; \"Target not found\" &lt;&lt; endl;\n    }\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q29. Implement Disjoint Set Union (Union-Find) with path compression and rank.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python implementation of Disjoint Set Union (Union-Find) with path compression and union by rank:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class DSU:\n    def __init__(self, n):\n        self.p = list(range(n))  # Parent array\n        self.r = &#91;0] * n         # Rank array\n\n    def find(self, x):\n        if self.p&#91;x] != x:\n            self.p&#91;x] = self.find(self.p&#91;x])  # Path compression\n        return self.p&#91;x]\n\n    def union(self, x, y):\n        x, y = self.find(x), self.find(y)\n        if x == y:\n            return False  # x and y are already in the same set\n        if self.r&#91;x] &lt; self.r&#91;y]:\n            x, y = y, x  # Ensure the tree with greater rank is the root\n        self.p&#91;y] = x\n        if self.r&#91;x] == self.r&#91;y]:  # Increment rank only when ranks are equal\n            self.r&#91;x] += 1\n        return True\n\n# Example usage\ndsu = DSU(5)  # Create DSU for 5 elements: 0, 1, 2, 3, 4\n\n# Union some sets\nprint(dsu.union(0, 1))  # True, 0 and 1 are now in the same set\nprint(dsu.union(2, 3))  # True, 2 and 3 are now in the same set\nprint(dsu.union(1, 2))  # True, 0-1 and 2-3 are now united\n\n# Find the representative of each element\nfor i in range(5):\n    print(f\"Find({i}) = {dsu.find(i)}\")\n\n\/\/ Output\nTrue\nTrue\nTrue\nFind(0) = 0\nFind(1) = 0\nFind(2) = 0\nFind(3) = 0\nFind(4) = 4\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q30. Find the maximum subarray sum (Kadane\u2019s algorithm).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python implementation of Kadane\u2019s Algorithm to find the maximum subarray sum:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def maxSubArray(nums):\n    if not nums:            # optional guard for empty list\n        return 0\n    max_end = max_so = nums&#91;0]\n    for x in nums&#91;1:]:\n        max_end = max(x, max_end + x)   # extend or start new subarray\n        max_so  = max(max_so, max_end)  # update max so far\n    return max_so\n\n# Test cases\nprint(maxSubArray(&#91;-2,1,-3,4,-1,2,1,-5,4]))  # 6   (subarray &#91;4,-1,2,1])\nprint(maxSubArray(&#91;1,2,3,4]))                # 10  (entire array)\nprint(maxSubArray(&#91;-1,-2,-3,-4]))            # -1  (the largest element)\nprint(maxSubArray(&#91;5, -2, 5, -1, 2]))        # 9   (subarray &#91;5, -2, 5, -1, 2])\nprint(maxSubArray(&#91;]))                       # 0   (with the empty-guard)\n<\/code><\/pre>\n\n\n\n<p><strong>\u2018Pro -Tip\u2019:<\/strong> For a comprehensive interview preparation, practice <a href=\"https:\/\/internshala.com\/blog\/infosys-hr-interview-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys HR interview questions<\/a> focusing on behavioral and situational scenarios. Strengthen your communication skills, build confidence, and ensure your responses reflect Infosys&#8217; core values to leave a lasting impression!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Infosys_Power_Programmer_Interview_Coding_Questions_on_String_Manipulation\"><\/span>Infosys Power Programmer Interview&nbsp; Coding Questions on String Manipulation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This section focuses on Infosys power programmer coding questions related to string manipulation. String-related problems are a common feature in coding interviews, testing your ability to efficiently handle operations such as searching, sorting, reversing, and pattern matching. Mastering these fundamental string operations will help you excel in the interview and demonstrate your problem-solving skills. Here are some questions you can practice:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q31. Given a string s, return a new string that is the reverse of s (e.g., &#8220;hello&#8221; \u2192 &#8220;olleh&#8221;).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>The function used takes a string s and returns a new string that is its reverse by swapping characters from both ends. Here\u2019s the code using C++:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;string&gt;\nusing namespace std;\n\n\/\/ Returns a new string that is the reverse of s\nstring reverseString(const string &amp;s) {\n    return string(s.rbegin(), s.rend());\n}\n\nint main() {\n    \/\/ Example inputs\n    string inputs&#91;] = {\"hello\", \"racecar\", \"\", \"A\"};\n    \n    for (const auto &amp;str : inputs) {\n        cout &lt;&lt; \"Original: \\\"\" &lt;&lt; str &lt;&lt; \"\\\"  \u2192  Reversed: \\\"\" \n             &lt;&lt; reverseString(str) &lt;&lt; \"\\\"\\n\";\n    }\n    \n    return 0;\n}\n\n\/\/ Output\nOriginal: \"hello\"  \u2192  Reversed: \"olleh\"\nOriginal: \"racecar\"  \u2192  Reversed: \"racecar\"\nOriginal: \"\"  \u2192  Reversed: \"\"\nOriginal: \"A\"  \u2192  Reversed: \"A\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q32. Determine whether a given string reads the same forwards and backwards, ignoring non-alphanumeric characters and case (e.g., &#8220;A man, a plan, a canal: Panama&#8221; \u2192 true).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>This function determines whether a given string is a palindrome by removing all non-alphanumeric characters and comparing the cleaned string to its reverse, case-insensitively.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;cctype&gt;\n#include &lt;string&gt;\nusing namespace std;\n\nbool isPalindrome(string s) {\n    int left = 0, right = s.length() - 1;\n    \n    while (left &lt; right) {\n        \/\/ Skip non-alphanumeric characters on the left\n        if (!isalnum(s&#91;left])) {\n            left++;\n        }\n        \/\/ Skip non-alphanumeric characters on the right\n        else if (!isalnum(s&#91;right])) {\n            right--;\n        }\n        \/\/ Compare characters (case-insensitive)\n        else if (tolower(s&#91;left]) != tolower(s&#91;right])) {\n            return false; \/\/ Not a palindrome\n        } else {\n            left++;\n            right--;\n        }\n    }\n    \n    return true; \/\/ It is a palindrome\n}\n\nint main() {\n    string str = \"A man, a plan, a canal: Panama\";\n    if (isPalindrome(str)) {\n        cout &lt;&lt; \"The string is a palindrome.\" &lt;&lt; endl;\n    } else {\n        cout &lt;&lt; \"The string is not a palindrome.\" &lt;&lt; endl;\n    }\n\n    return 0;\n}\n\n\/\/ Output\nThe string is a palindrome.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q33. Given two strings s and t, determine if t is an anagram of s (i.e., they contain the same characters in any order).&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a JavaScript program determining if t is an anagram of s:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function isAnagram(s, t) {\n    if (s.length !== t.length) return false;\n    const count = {};\n    for (let c of s) count&#91;c] = (count&#91;c] || 0) + 1;\n    for (let c of t) {\n        if (!count&#91;c]) return false;\n        count&#91;c]--;\n    }\n    return true;\n}\n\n\/\/ Example usage and expected output:\nconsole.log(isAnagram(\"anagram\", \"nagaram\")); \/\/ true\nconsole.log(isAnagram(\"rat\",     \"car\"));     \/\/ false\nconsole.log(isAnagram(\"aacc\",    \"ccac\"));    \/\/ false\nconsole.log(isAnagram(\"\",        \"\"));        \/\/ true\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q34. Find the first character in a string that does not repeat (e.g., &#8220;leetcode&#8221; \u2192 &#8216;l&#8217;).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a solution in a C++ program to find the first character in a string that does not repeat:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;unordered_map&gt;\n#include &lt;string&gt;\nusing namespace std;\n\nchar firstUniqChar(const string &amp;s) {\n    unordered_map&lt;char, int&gt; count;\n\n    \/\/ Count the frequency of each character\n    for (char c : s) {\n        count&#91;c]++;\n    }\n\n    \/\/ Find the first character with a frequency of 1\n    for (char c : s) {\n        if (count&#91;c] == 1) {\n            return c;\n        }\n    }\n\n    \/\/ If no unique character is found\n    return ' '; \/\/ return a space if no unique character exists\n}\n\nint main() {\n    string s = \"leetcode\";\n    char result = firstUniqChar(s);\n\n    if (result != ' ') {\n        cout &lt;&lt; \"Input: \\\"\" &lt;&lt; s &lt;&lt; \"\\\"\" &lt;&lt; endl;\n        cout &lt;&lt; \"Output: The first non-repeating character is: \" &lt;&lt; result &lt;&lt; endl;\n    } else {\n        cout &lt;&lt; \"Input: \\\"\" &lt;&lt; s &lt;&lt; \"\\\"\" &lt;&lt; endl;\n        cout &lt;&lt; \"Output: No unique character found.\" &lt;&lt; endl;\n    }\n\n    return 0;\n}\n\n\/\/ Output\nstring s = \"leetcode\";\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q35. Implement atoi, converting a string to a 32-bit signed integer with proper overflow handling.&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a Python program implementing <strong>atoi, <\/strong>converting a string to a 32-bit signed integer with proper overflow handling:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def my_atoi(s: str) -&gt; int:\n    s = s.lstrip()  # Remove leading spaces\n    if not s: \n        return 0  # Empty string or only spaces\n\n    sign, i = 1, 0\n    # Check for optional sign at the start\n    if s&#91;0] in '+-':\n        sign = -1 if s&#91;0] == '-' else 1\n        i = 1\n\n    num = 0\n    # Parse digits\n    while i &lt; len(s) and s&#91;i].isdigit():\n        num = num * 10 + int(s&#91;i])\n        i += 1\n    \n    # Apply sign\n    num *= sign\n    \n    # Handle overflow\n    return max(-2**31, min(num, 2**31 - 1))\n\n# Example usage:\nprint(my_atoi(\"42\"))  # 42\nprint(my_atoi(\"   -42\"))  # -42\nprint(my_atoi(\"4193 with words\"))  # 4193\nprint(my_atoi(\"words and 987\"))  # 0\nprint(my_atoi(\"-91283472332\"))  # -2147483648\nprint(my_atoi(\"2147483648\"))  # 2147483647\nprint(my_atoi(\"-2147483649\"))  # -2147483648\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q36. Given a string s, find the length of the longest substring without repeating characters (e.g., &#8220;abcabcbb&#8221; \u2192 3).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a JavaScript program finding the longest substring without repeating characters:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function lengthOfLongestSubstring(s) {\n    let map = new Map(); \/\/ To store characters and their most recent index\n    let left = 0; \/\/ Left pointer of the sliding window\n    let maxLength = 0; \/\/ To store the length of the longest substring\n\n    \/\/ Loop through each character in the string using a right pointer\n    for (let right = 0; right &lt; s.length; right++) {\n        \/\/ If the character is already in the map and is within the window\n        if (map.has(s&#91;right]) &amp;&amp; map.get(s&#91;right]) &gt;= left) {\n            \/\/ Move the left pointer to the right of the last occurrence of s&#91;right]\n            left = map.get(s&#91;right]) + 1;\n        }\n\n        \/\/ Update the map with the current character's index\n        map.set(s&#91;right], right);\n\n        \/\/ Calculate the length of the current substring and update maxLength if it's larger\n        maxLength = Math.max(maxLength, right - left + 1);\n    }\n\n    return maxLength;\n}\n\n\/\/ Example usage\nlet s = \"abcabcbb\";\nconsole.log(lengthOfLongestSubstring(s));  \/\/ Output: 3\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q37. Return the index of the first occurrence of needle in haystack, or -1 if not found (e.g., &#8220;hello&#8221;, &#8220;ll&#8221; \u2192 2).&nbsp;<\/h3>\n\n\n\n<p><strong>Answer:<\/strong> Here is the solution in a C++ program returning the index of the first occurrence of needle in haystack, or -1 if not found :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;string&gt;\nusing namespace std;\n\nint strStr(string haystack, string needle) {\n    \/\/ Check if needle is empty, return 0\n    if (needle.empty()) return 0;\n    \n    \/\/ Loop through the haystack, checking for the first occurrence of needle\n    for (int i = 0; i &lt;= haystack.length() - needle.length(); i++) {\n        if (haystack.substr(i, needle.length()) == needle) {\n            return i;\n        }\n    }\n    \/\/ Return -1 if needle is not found\n    return -1;\n}\n\nint main() {\n    string haystack = \"hello\";\n    string needle = \"ll\";\n    \n    \/\/ Test the function and print the result\n    cout &lt;&lt; \"Index of first occurrence: \" &lt;&lt; strStr(haystack, needle) &lt;&lt; endl;  \/\/ Output: 2\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q38. Given two non-negative integer strings num1 and num2, return their sum as a string (e.g., &#8220;123&#8221; + &#8220;77&#8221; \u2192 &#8220;200&#8221;).&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the sum of two non-negative integer strings in a Python program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def addStrings(num1, num2):\n    # Initialize two pointers for both strings and a carry variable\n    i, j, carry, result = len(num1) - 1, len(num2) - 1, 0, &#91;]\n    \n    # Loop until we've processed all digits or there's no carry left\n    while i &gt;= 0 or j &gt;= 0 or carry:\n        # Get current digits or 0 if we've run out of digits\n        digit1 = int(num1&#91;i]) if i &gt;= 0 else 0\n        digit2 = int(num2&#91;j]) if j &gt;= 0 else 0\n        \n        # Calculate the sum of the current digits plus carry\n        total = digit1 + digit2 + carry\n        \n        # Update carry for the next step\n        carry = total \/\/ 10\n        \n        # Append the current digit to the result (total % 10 gives the last digit)\n        result.append(str(total % 10))\n        \n        # Move the pointers to the left\n        i -= 1\n        j -= 1\n    \n    # Since we've added digits in reverse order, reverse the result and return it\n    return ''.join(result&#91;::-1])\n\n# Example usage\nnum1 = \"123\"\nnum2 = \"77\"\nprint(addStrings(num1, num2))  # Output: \"200\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q39. Given strings s and t, find the smallest substring in s that contains all characters of t (e.g., s = &#8220;ADOBECODEBANC&#8221;, t = &#8220;ABC&#8221; \u2192 &#8220;BANC&#8221;).<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a C++ program to find the smallest substring:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;string&gt;\n#include &lt;unordered_map&gt;\n#include &lt;climits&gt;\nusing namespace std;\n\nstring minWindow(string s, string t) {\n    unordered_map&lt;char,int&gt; need, window;\n    for (char c : t) need&#91;c]++;\n    int have = 0, required = need.size(), left = 0, minLen = INT_MAX, start = 0;\n    for (int right = 0; right &lt; s.size(); right++) {\n        char c = s&#91;right];\n        if (++window&#91;c] == need&#91;c]) have++;\n        while (have == required) {\n            if (right - left + 1 &lt; minLen) {\n                minLen = right - left + 1;\n                start = left;\n            }\n            if (--window&#91;s&#91;left]] &lt; need&#91;s&#91;left]]) have--;\n            left++;\n        }\n    }\n    return (minLen == INT_MAX) ? \"\" : s.substr(start, minLen);\n}\n\nint main() {\n    string s = \"ADOBECODEBANC\";\n    string t = \"ABC\";\n    \n    cout &lt;&lt; \"Smallest substring: \" &lt;&lt; minWindow(s, t) &lt;&lt; endl;  \/\/ Output: \"BANC\"\n    \n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q40. Determine if s2 is a rotation of s1 using a single substring check (e.g., &#8220;waterbottle&#8221; is a rotation of &#8220;erbottlewat&#8221;).&nbsp;<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the solution in a JavaScript program to determine if s2 is a rotation of s1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function isRotation(s1, s2) {\n    if (s1.length !== s2.length || s1.length === 0) {\n        return false;\n    }\n    const combined = s1 + s1;\n    return combined.includes(s2);\n}\n\n\/\/ Example usage\nconsole.log(isRotation(\"waterbottle\", \"erbottlewat\")); \/\/ Output: true\nconsole.log(isRotation(\"hello\", \"llohe\"));             \/\/ Output: true\nconsole.log(isRotation(\"hello\", \"olelh\"));             \/\/ Output: false\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q41. Given an array of strings, group the anagrams together.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here\u2019s how to group anagrams in a C++ program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;string&gt;\n#include &lt;unordered_map&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nvector&lt;vector&lt;string&gt;&gt; groupAnagrams(vector&lt;string&gt;&amp; strs) {\n    unordered_map&lt;string, vector&lt;string&gt;&gt; anagramMap;\n\n    for (string word : strs) {\n        string sortedWord = word;\n        sort(sortedWord.begin(), sortedWord.end());\n        anagramMap&#91;sortedWord].push_back(word);\n    }\n\n    vector&lt;vector&lt;string&gt;&gt; result;\n    for (auto&amp; pair : anagramMap) {\n        result.push_back(pair.second);\n    }\n\n    return result;\n}\n\nint main() {\n    vector&lt;string&gt; words = {\"eat\", \"tea\", \"tan\", \"ate\", \"nat\", \"bat\"};\n    vector&lt;vector&lt;string&gt;&gt; groups = groupAnagrams(words);\n\n    for (const auto&amp; group : groups) {\n        for (const auto&amp; word : group) {\n            cout &lt;&lt; word &lt;&lt; \" \";\n        }\n        cout &lt;&lt; endl;\n    }\n\n    return 0;\n}\n\n\/\/Output\neat tea ate \ntan nat \nbat \n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q42. Given a string s, return the longest palindromic substring in s.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the code in a Python program to return the longest palindromic substring in s:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def longest_palindrome(s):\n    if not s or len(s) &lt; 1:\n        return \"\"\n\n    def expand_around_center(left, right):\n        while left &gt;= 0 and right &lt; len(s) and s&#91;left] == s&#91;right]:\n            left -= 1\n            right += 1\n        return s&#91;left + 1:right]\n\n    longest = \"\"\n    for i in range(len(s)):\n        # Odd length palindrome\n        temp1 = expand_around_center(i, i)\n        # Even length palindrome\n        temp2 = expand_around_center(i, i + 1)\n\n        # Update the longest palindrome found so far\n        if len(temp1) &gt; len(longest):\n            longest = temp1\n        if len(temp2) &gt; len(longest):\n            longest = temp2\n\n    return longest\n\n\/\/ Example usage:\ninput_str = \"babad\"\nprint(longest_palindrome(input_str))  # Output: \"bab\" or \"aba\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q43. Given two strings s and t, determine if they are isomorphic.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is a code in a JavaScript program to determine if <strong>s <\/strong>and<strong> t <\/strong>are isomorphic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffunction isIsomorphic(s, t) {\n    if (s.length !== t.length) return false;\n\n    const mapST = new Map();\n    const mapTS = new Map();\n\n    for (let i = 0; i &lt; s.length; i++) {\n        const charS = s&#91;i];\n        const charT = t&#91;i];\n\n        if (mapST.has(charS)) {\n            if (mapST.get(charS) !== charT) return false;\n        } else {\n            mapST.set(charS, charT);\n        }\n\n        if (mapTS.has(charT)) {\n            if (mapTS.get(charT) !== charS) return false;\n        } else {\n            mapTS.set(charT, charS);\n        }\n    }\n\n    return true;\n}\n\n\/\/ Example usage:\nconsole.log(isIsomorphic(\"egg\", \"add\"));  \/\/ Output: true\nconsole.log(isIsomorphic(\"foo\", \"bar\"));  \/\/ Output: false\nconsole.log(isIsomorphic(\"paper\", \"title\"));  \/\/ Output: true\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q44. Given a string containing just the characters &#8216;(&#8216;, &#8216;)&#8217;, &#8216;{&#8216;, &#8216;}&#8217;, &#8216;[&#8216;, and &#8216;]&#8217;, determine if the input string is valid. An input string is valid if:<\/h3>\n\n\n\n<ul>\n<li><strong>Open brackets are closed by the same type of brackets.<\/strong><\/li>\n\n\n\n<li><strong>Open brackets are closed in the correct order.<\/strong><\/li>\n<\/ul>\n\n\n\n<p><strong>Answer: <\/strong>Here is a Python program to determine whether the input string is valid or not:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def is_valid(s):\n    stack = &#91;]\n    bracket_map = {')': '(', '}': '{', ']': '&#91;'}\n\n    for char in s:\n        if char in bracket_map.values():  # opening brackets\n            stack.append(char)\n        elif char in bracket_map:  # closing brackets\n            if not stack or stack&#91;-1] != bracket_map&#91;char]:\n                return False\n            stack.pop()\n        else:\n            # Ignore any characters that are not brackets (optional)\n            return False\n\n    return len(stack) == 0\n\n\/\/ Example usage:\ninput_str = \"({&#91;]})\"\nprint(is_valid(input_str))  # Output: True\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q45. Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string &#8220;&#8221;.<\/h3>\n\n\n\n<p><strong>Answer: <\/strong>Here is the function to find the longest common prefix string among an array of strings in a C++ program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;vector&gt;\n#include &lt;string&gt;\nusing namespace std;\n\nstring longestCommonPrefix(vector&lt;string&gt;&amp; strs) {\n    if (strs.empty()) return \"\";\n    \n    for (int i = 0; i &lt; strs&#91;0].size(); ++i) {\n        char c = strs&#91;0]&#91;i];\n        for (int j = 1; j &lt; strs.size(); ++j) {\n            if (i &gt;= strs&#91;j].size() || strs&#91;j]&#91;i] != c) {\n                return strs&#91;0].substr(0, i);\n            }\n        }\n    }\n    return strs&#91;0];\n}\n\n\n\/\/ Example usage:\nvector&lt;string&gt; words = {\"flower\", \"flow\", \"flight\"};\ncout &lt;&lt; longestCommonPrefix(words);  \/\/ Output: \"fl\"\n<\/code><\/pre>\n\n\n\n<p><strong>Pro Tip: <\/strong>Strengthen your interview preparation by exploring our <a href=\"https:\/\/internshala.com\/blog\/infosys-interview-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Infosys interview questions and answers<\/a> guide blog. Gain insights into technical, HR, and aptitude rounds to boost your confidence and improve your chances of success!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Tips_to_Prepare_for_Infosys_Power_Programmer_Interview\"><\/span>Tips to Prepare for Infosys Power Programmer Interview<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Infosys power programmer coding interview is a challenging process. It assesses candidates&#8217; technical proficiency, problem-solving skills, and coding expertise. Successful interview preparation requires a well-structured strategy that enhances both technical knowledge and your confidence. Here are essential steps to boost your readiness:<\/p>\n\n\n\n<ol>\n<li><strong>Practice Mock Interviews:<\/strong> Try real interview scenarios by engaging in mock sessions, using online platforms, and studying insights from experts and past candidates.<\/li>\n\n\n\n<li><strong>Learn from Previous Candidates&#8217; Experiences: <\/strong>Connect with former applicants and review their shared strategies, challenges, and mistakes to refine your approach.<\/li>\n\n\n\n<li><strong>Utilize Guides &amp; Training Courses: <\/strong>Strengthen technical skills through certification programs, study materials, and structured learning paths tailored for the job role.<\/li>\n\n\n\n<li><strong>Develop Strong Coding Skills:<\/strong> Regularly solve coding problems, practice algorithm-based challenges, and refine problem-solving techniques to boost efficiency.<\/li>\n\n\n\n<li><strong>Revise Core Programming Concepts:<\/strong> Utilize notes, flashcards, and quizzes to reinforce essential data structures, algorithms, and system design principles before the interview.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large desktop-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-power-programmer-coding-questions&amp;utm_campaign=candidate-web-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg\" alt=\"Find and Apply Banner\" class=\"wp-image-21795\" srcset=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1024x203.jpg 1024w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-672x133.jpg 672w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-1536x305.jpg 1536w, https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Find-and-Apply-Banner-2048x406.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full mobile-image\"><a href=\"https:\/\/internshala.com\/jobs\/?utm_source=is_blog&amp;utm_medium=infosys-power-programmer-coding-questions&amp;utm_campaign=candidate-mobile-banner\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"256\" src=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2024\/01\/Job-Banner-for-candidates.jpg\" alt=\"Job Banner for candidates\" class=\"wp-image-21794\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Preparing for the Infosys power programmer coding questions demands a well-structured approach, solid coding fundamentals, and practical problem-solving skills. Regardless of your experience, focusing on key concepts, sharpening your coding abilities, and reinforcing your theoretical knowledge will significantly improve your chances of success. Consistent practice of mock interviews will help you gain confidence and minimize mistakes during the actual interview. To further boost your preparation, leverage candidate experiences, study guides, and hands-on coding exercises. For additional insights, don&#8217;t forget to explore our blogs on the Infosys coding interview questions and answers to enhance your readiness.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1746594681454\"><strong class=\"schema-faq-question\">Q1. <strong>What is the role of a power programmer at Infosys?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer: <\/strong>A power programmer at Infosys is a highly proficient technologist capable of working across a wide range of technologies. They contribute to complex, high-impact projects often involving full-stack development. They are skilled in emerging domains such as machine learning, big data, and cloud computing.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1746594695127\"><strong class=\"schema-faq-question\">Q<strong>2. What is the exam pattern for Infosys 2025?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer: <\/strong>The Infosys 2025 recruitment exam is structured to evaluate candidates on core aptitude and programming skills. The exam typically consists of 67 questions across four sections:<br\/><br\/>1. Quantitative Aptitude\u00a0<br\/>2. Logical Reasoning\u00a0<br\/>3. Verbal Ability\u00a0<br\/>4. Coding Round<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1746594735415\"><strong class=\"schema-faq-question\">Q<strong>3. Does the Infosys interview include a coding round?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Answer: <\/strong>Yes, Infosys typically conducts a coding round as part of its selection process, along with an aptitude section that assesses logical reasoning, quantitative aptitude, and verbal ability.<\/p> <\/div> <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Sources<\/h3>\n\n\n\n<ul>\n<li>https:\/\/www.infosys.com\/careers\/power-programmers.html<\/li>\n<\/ul>\n<aside class=\"mashsb-container mashsb-main \"><div class=\"mashsb-box\"><div class=\"mashsb-count mash-medium\" style=\"float:left\"><div class=\"counts mashsbcount\">0<\/div><span class=\"mashsb-sharetext\">SHARES<\/span><\/div><div class=\"mashsb-buttons\"><a class=\"mashicon-facebook mash-medium mashsb-noshadow\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Finternshala.com%2Fblog%2Finfosys-power-programmer-coding-questions-and-answers%2F\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Share&nbsp;on&nbsp;Facebook<\/span><\/a><a class=\"mashicon-subscribe mash-medium mashsb-noshadow\" href=\"#\" target=\"_top\" rel=\"nofollow\"><span class=\"icon\"><\/span><span class=\"text\">Get&nbsp;Your&nbsp;Dream&nbsp;Internship<\/span><\/a><div class=\"onoffswitch2 mash-medium mashsb-noshadow\" style=\"display:none\"><\/div><\/div>\n            <\/div>\n                <div style=\"clear:both\"><\/div><\/aside>\n            <!-- Share buttons by mashshare.net - Version: 4.0.42-->","protected":false},"excerpt":{"rendered":"<p>You know? The Power Programmer unit at Infosys includes over 3,000 elite engineers, representing the top 1% of the company\u2019s global engineering talent. Infosys, a global leader in IT consulting<\/p>\n","protected":false},"author":6498,"featured_media":27213,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4316],"tags":[9858],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Top 45 Infosys Power Programmer Coding Questions and Answers<\/title>\n<meta name=\"description\" content=\"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 45 Infosys Power Programmer Coding Questions and Answers\" \/>\n<meta property=\"og:description\" content=\"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"Internshala blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-07T05:45:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T05:35:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2025\/05\/infosys-power-programmer-coding-questionsnew.png\" \/>\n\t<meta property=\"og:image:width\" content=\"390\" \/>\n\t<meta property=\"og:image:height\" content=\"255\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Shailja Kaushik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shailja Kaushik\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\"},\"author\":{\"name\":\"Shailja Kaushik\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b\"},\"headline\":\"Infosys Power Programmer Coding Questions and Answers\",\"datePublished\":\"2025-05-07T05:45:15+00:00\",\"dateModified\":\"2026-03-16T05:35:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\"},\"wordCount\":2686,\"publisher\":{\"@id\":\"https:\/\/internshala.com\/blog\/#organization\"},\"keywords\":[\"Infosys Power Programmer Coding Questions\"],\"articleSection\":[\"Interview Guide\"],\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\",\"url\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\",\"name\":\"Top 45 Infosys Power Programmer Coding Questions and Answers\",\"isPartOf\":{\"@id\":\"https:\/\/internshala.com\/blog\/#website\"},\"datePublished\":\"2025-05-07T05:45:15+00:00\",\"dateModified\":\"2026-03-16T05:35:28+00:00\",\"description\":\"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.\",\"breadcrumb\":{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454\"},{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127\"},{\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/internshala.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Job Tips\",\"item\":\"https:\/\/internshala.com\/blog\/job-tips\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Interview Guide\",\"item\":\"https:\/\/internshala.com\/blog\/job-tips\/interview-guide\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Infosys Power Programmer Coding Questions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/internshala.com\/blog\/#website\",\"url\":\"https:\/\/internshala.com\/blog\/\",\"name\":\"Internshala blog\",\"description\":\"Your favourite senior outside college\",\"publisher\":{\"@id\":\"https:\/\/internshala.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/internshala.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/internshala.com\/blog\/#organization\",\"name\":\"Internshala blog\",\"url\":\"https:\/\/internshala.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png\",\"contentUrl\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png\",\"width\":112,\"height\":31,\"caption\":\"Internshala blog\"},\"image\":{\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b\",\"name\":\"Shailja Kaushik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/internshala.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg\",\"contentUrl\":\"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg\",\"caption\":\"Shailja Kaushik\"},\"description\":\"Shailja Kaushik has been an Editor with Internshala since March 2023. She loves creative writing and experimenting with different forms of writing. She has explored different genres by working with journals and radio stations. She has also published her poems and nano tales in various anthologies. She graduated at the top of her class with Bachelor's in English and recently completed her Master's in English from the University of Delhi. Her experiments with writing continue on her literary blog.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/shailja-kaushik\/\"],\"url\":\"https:\/\/internshala.com\/blog\/author\/shailja\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454\",\"position\":1,\"url\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454\",\"name\":\"Q1. What is the role of a power programmer at Infosys?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer: <\/strong>A power programmer at Infosys is a highly proficient technologist capable of working across a wide range of technologies. They contribute to complex, high-impact projects often involving full-stack development. They are skilled in emerging domains such as machine learning, big data, and cloud computing.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127\",\"position\":2,\"url\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127\",\"name\":\"Q2. What is the exam pattern for Infosys 2025?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer: <\/strong>The Infosys 2025 recruitment exam is structured to evaluate candidates on core aptitude and programming skills. The exam typically consists of 67 questions across four sections:<br\/><br\/>1. Quantitative Aptitude\u00a0<br\/>2. Logical Reasoning\u00a0<br\/>3. Verbal Ability\u00a0<br\/>4. Coding Round\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415\",\"position\":3,\"url\":\"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415\",\"name\":\"Q3. Does the Infosys interview include a coding round?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Answer: <\/strong>Yes, Infosys typically conducts a coding round as part of its selection process, along with an aptitude section that assesses logical reasoning, quantitative aptitude, and verbal ability.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Top 45 Infosys Power Programmer Coding Questions and Answers","description":"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.","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:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"Top 45 Infosys Power Programmer Coding Questions and Answers","og_description":"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.","og_url":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/","og_site_name":"Internshala blog","article_published_time":"2025-05-07T05:45:15+00:00","article_modified_time":"2026-03-16T05:35:28+00:00","og_image":[{"width":390,"height":255,"url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2025\/05\/infosys-power-programmer-coding-questionsnew.png","type":"image\/png"}],"author":"Shailja Kaushik","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Shailja Kaushik","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#article","isPartOf":{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/"},"author":{"name":"Shailja Kaushik","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b"},"headline":"Infosys Power Programmer Coding Questions and Answers","datePublished":"2025-05-07T05:45:15+00:00","dateModified":"2026-03-16T05:35:28+00:00","mainEntityOfPage":{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/"},"wordCount":2686,"publisher":{"@id":"https:\/\/internshala.com\/blog\/#organization"},"keywords":["Infosys Power Programmer Coding Questions"],"articleSection":["Interview Guide"],"inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/","url":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/","name":"Top 45 Infosys Power Programmer Coding Questions and Answers","isPartOf":{"@id":"https:\/\/internshala.com\/blog\/#website"},"datePublished":"2025-05-07T05:45:15+00:00","dateModified":"2026-03-16T05:35:28+00:00","description":"Discover top Infosys Power Programmer coding questions, along with insights into the recruitment process and effective preparation strategies.","breadcrumb":{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454"},{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127"},{"@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/internshala.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Job Tips","item":"https:\/\/internshala.com\/blog\/job-tips\/"},{"@type":"ListItem","position":3,"name":"Interview Guide","item":"https:\/\/internshala.com\/blog\/job-tips\/interview-guide\/"},{"@type":"ListItem","position":4,"name":"Infosys Power Programmer Coding Questions"}]},{"@type":"WebSite","@id":"https:\/\/internshala.com\/blog\/#website","url":"https:\/\/internshala.com\/blog\/","name":"Internshala blog","description":"Your favourite senior outside college","publisher":{"@id":"https:\/\/internshala.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/internshala.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/internshala.com\/blog\/#organization","name":"Internshala blog","url":"https:\/\/internshala.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png","contentUrl":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/08\/LOGO-1.png","width":112,"height":31,"caption":"Internshala blog"},"image":{"@id":"https:\/\/internshala.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/e9d693573cfd7df9145f7f1a0f6e523b","name":"Shailja Kaushik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/internshala.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg","contentUrl":"https:\/\/internshala.com\/blog\/wp-content\/uploads\/2023\/09\/Shailja-Kaushik-96x96.jpg","caption":"Shailja Kaushik"},"description":"Shailja Kaushik has been an Editor with Internshala since March 2023. She loves creative writing and experimenting with different forms of writing. She has explored different genres by working with journals and radio stations. She has also published her poems and nano tales in various anthologies. She graduated at the top of her class with Bachelor's in English and recently completed her Master's in English from the University of Delhi. Her experiments with writing continue on her literary blog.","sameAs":["https:\/\/www.linkedin.com\/in\/shailja-kaushik\/"],"url":"https:\/\/internshala.com\/blog\/author\/shailja\/"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454","position":1,"url":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594681454","name":"Q1. What is the role of a power programmer at Infosys?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer: <\/strong>A power programmer at Infosys is a highly proficient technologist capable of working across a wide range of technologies. They contribute to complex, high-impact projects often involving full-stack development. They are skilled in emerging domains such as machine learning, big data, and cloud computing.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127","position":2,"url":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594695127","name":"Q2. What is the exam pattern for Infosys 2025?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer: <\/strong>The Infosys 2025 recruitment exam is structured to evaluate candidates on core aptitude and programming skills. The exam typically consists of 67 questions across four sections:<br\/><br\/>1. Quantitative Aptitude\u00a0<br\/>2. Logical Reasoning\u00a0<br\/>3. Verbal Ability\u00a0<br\/>4. Coding Round","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415","position":3,"url":"https:\/\/internshala.com\/blog\/infosys-power-programmer-coding-questions-and-answers\/#faq-question-1746594735415","name":"Q3. Does the Infosys interview include a coding round?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Answer: <\/strong>Yes, Infosys typically conducts a coding round as part of its selection process, along with an aptitude section that assesses logical reasoning, quantitative aptitude, and verbal ability.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts\/27205"}],"collection":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/users\/6498"}],"replies":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/comments?post=27205"}],"version-history":[{"count":0,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/posts\/27205\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/media\/27213"}],"wp:attachment":[{"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/media?parent=27205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/categories?post=27205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internshala.com\/blog\/wp-json\/wp\/v2\/tags?post=27205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}