[{"id":"ttwe","title":"Sum of even and odd","order":"0","problemStatement":"Arun and Kalai were playing a puzzle game with a given set of numbers.\n\nThey need to find the odd and even numbers and find the sum of the odd numbers and the sum of the even numbers.\n\nWrite a program to help them to solve the puzzle game and to win the mobile phone.\n\n\nInput Format:\n\nInput consists of n+1 integers. \n\nThe first integer corresponds to \u2018n\u2019, the size of the array. \n\nThe next \u2018n\u2019 integers correspond to the elements in the array. \n\nAssume that the maximum value of n is 15.\n\n \n\nOutput Format:\n\nRefer to sample output for details.","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n\\n2\\n\\n3\\n\\n6\\n\\n8\\n\\n-1\",\"outputText\":\"The sum of the even numbers in the array is 16\\nThe sum of the odd numbers in the array is 2\"},{\"id\":\"2\",\"inputText\":\"5\\n2\\n4\\n7\\n8\\n1\",\"outputText\":\"The sum of the even numbers in the array is 14\\nThe sum of the odd numbers in the array is 8\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":null},{"id":"test-tcs-1","title":"TCS-Ques-1","order":"0","problemStatement":"Given an array Arr[] of N integers and a positive integer K, cyclically rotate the array clockwise by K. Print the Rotated Array. First input is Number of elements in an array. Second input is array elements. Third input is number of rotation","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n10 20 30 40 50\\n2\",\"outputText\":\"40 50 10 20 30\"},{\"id\":\"2\",\"inputText\":\"6\\n1 2 3 4 5 6\\n3\",\"outputText\":\"4 5 6 1 2 3\"},{\"id\":\"3\",\"inputText\":\"7\\n11 22 33 44 55 66 77\\n4\\n\",\"outputText\":\"44 55 66 77 11 22 33\"},{\"id\":\"4\",\"inputText\":\"4\\n5 10 15 20\\n1\",\"outputText\":\"20 5 10 15\"},{\"id\":\"5\",\"inputText\":\"8\\n9 8 7 6 5 4 3 2\\n5\",\"outputText\":\"6 5 4 3 2 9 8 7 \"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>\n#include <stdlib.h>\n\nvoid rotate(int nums[], int n, int k, int ans[]) {\n    k = k % n;\n    \n    for (int i = 0; i < k; i++) {\n        ans[i] = nums[n - k + i];\n    }\n    \n    int index = 0;\n    for (int i = k; i < n; i++) {\n        ans[i] = nums[index++];\n    }\n}\n\nint main() {\n    int N, K;\n    scanf(\"%d\", &N);\n    \n    int *Array = (int *)malloc(N * sizeof(int));\n    int *ans = (int *)malloc(N * sizeof(int));\n\n    for (int i = 0; i < N; ++i) {\n        scanf(\"%d\", &Array[i]);\n    }\n    \n    scanf(\"%d\", &K);\n    \n    rotate(Array, N, K, ans);\n    \n    for (int i = 0; i < N; ++i) {\n        printf(\"%d \", ans[i]);\n    }\n    \n    free(Array);\n    free(ans);\n\n    return 0;\n}\n"},{"id":"test-tcs-2","title":"TCS-Ques-2","order":"1","problemStatement":" In this 3 Palindrome, Given an input string word, split the string into exactly 3 palindromic substrings. Working from left to right, choose the smallest split for the first substring that still allows the remaining word to be split into 2 palindromes.\n\nSimilarly, choose the smallest second palindromic substring that leaves a third palindromic substring.\n\nIf there is no way to split the word into exactly three palindromic substrings, print \u201cImpossible\u201d (without quotes). Every character of the string needs to be consumed.\n\nCases not allowed \u2013\n\nAfter finding 3 palindromes using above instructions, if any character of the original string remains unconsumed.\nNo character may be shared in forming 3 palindromes.\n\nInput\n\nFirst line contains the input string consisting of characters between [a-z].\nOutput\n\nPrint 3 substrings one on each line.\nTime Limit\n\n1\n\nExplanation\nFor the second case\nExplanation\n\nThe other ways to split the given string into 3 palindromes are as follows \u2013\n[a, aaa, a], [aaa, a, a], [aa, aa, a], etc.\nSince we want to minimize the length of the first palindromic substring using left to right processing, the correct way to split is [a, a, aaa].\n\n","examples":"[{\"id\":\"1\",\"inputText\":\"nayannamantenet\",\"outputText\":\"nayan\\nnaman\\ntenet\"},{\"id\":\"2\",\"inputText\":\"aaaaa\",\"outputText\":\"a\\na\\naaa\"},{\"id\":\"3\",\"inputText\":\"aaaabaaaa\",\"outputText\":\"a\\naaabaaa\\na\"},{\"id\":\"4\",\"inputText\":\"racecarlevelwow\",\"outputText\":\"racecar\\nlevel\\nwow\"},{\"id\":\"5\",\"inputText\":\"abcdcbaefggfe\",\"outputText\":\"Impossible\"}]","constraints":"1 <= the length of input sting <= 1000","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>\n#include <string.h>\n#include <stdbool.h>\n\n\/\/ Function to check if a given string is palindrome\nbool isPalindrome(char *s, int start, int end) {\n    while (start < end) {\n        if (s[start] != s[end]) {\n            return false;\n        }\n        start++;\n        end--;\n    }\n    return true;\n}\n\nint main() {\n    char s[1005]; \/\/ Assuming max length of string is 1000\n    scanf(\"%s\", s);\n    \n    int l = strlen(s);\n    char s1[1005], s2[1005], s3[1005];\n\n    \/\/ Iterate over all possible first partitions\n    for (int i = 1; i < l - 1; i++) {\n        if (isPalindrome(s, 0, i - 1)) { \/\/ First part must be a palindrome\n            \/\/ Iterate over all possible second partitions\n            for (int j = 1; j < l - i; j++) {\n                if (isPalindrome(s, i, i + j - 1) && isPalindrome(s, i + j, l - 1)) {\n                    strncpy(s1, s, i); \n                    s1[i] = '\\0';\n\n                    strncpy(s2, s + i, j);\n                    s2[j] = '\\0';\n\n                    strcpy(s3, s + i + j);\n\n                    printf(\"%s\\n%s\\n%s\\n\", s1, s2, s3);\n                    return 0;\n                }\n            }\n        }\n    }\n    printf(\"Impossible\\n\");\n    return 0;\n}\n"},{"id":"test-tcs-3","title":"TCS-Ques-3","order":"0","problemStatement":"Write a program to segregate all the 0\u2019s in left side and 1\u2019s in right side in the same array with O(n) complexity. \n","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n0 1 0 1 0\",\"outputText\":\"0 0 0 1 1 \"},{\"id\":\"2\",\"inputText\":\"6\\n1 0 1 0 1 0\",\"outputText\":\"0 0 0 1 1 1 \"},{\"id\":\"3\",\"inputText\":\"8\\n1 1 1 1 0 0 1 0\",\"outputText\":\"0 0 0 1 1 1 1 1 \"},{\"id\":\"4\",\"inputText\":\"2\\n1 0 \",\"outputText\":\"0 1\"},{\"id\":\"5\",\"inputText\":\"3\\n1 0 1\",\"outputText\":\"0 1 1\"}]","constraints":"No constraints0 < Row <=10  0 < Column <=10  0 < Number Of Rotations <=10","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>  \nvoid segregate0and1(int arr[], int n)\n{   \n\tint left = 0, right = n-1;       \n\twhile(1)     \n\t{       \n\t\tif(left >= right)              \n\t\t\tbreak;       \n\t\tif(arr[left] == 0) \n\t\t\tleft++;          \n\t\telse if(arr[right] == 1) \n\t\t\tright--; \n\t\telse\n\t\t{         \n\t\t\tarr[left]  = 0;         \n\t\t\tarr[right] = 1;         \n\t\t\tleft++;         \n\t\t\tright--;       \n\t\t}     \n\t}\n} \nint main() \n{ \n\tint n;\n\tscanf(\"%d\",&n);\n\tint arr[n];\n\tfor(int i=0;i<n;i++)\n\t\tscanf(\"%d\",&arr[i]);\n\tsegregate0and1(arr, n); \n\tfor(int i=0;i<n;i++)\n\t\tprintf(\"%d \",arr[i]);\n\treturn 0; \n} \n"},{"id":"test-tcs-4","title":"TCS-Ques-4","order":"0","problemStatement":"Write a program to find the most occurring character in the string.\n","examples":"[{\"id\":\"1\",\"inputText\":\"Happy Coding\",\"outputText\":\"p\"},{\"id\":\"2\",\"inputText\":\"Welcome World\",\"outputText\":\"W\"},{\"id\":\"3\",\"inputText\":\"Sure Thinge\",\"outputText\":\"e\"},{\"id\":\"4\",\"inputText\":\"Fox brix\",\"outputText\":\"x\"},{\"id\":\"5\",\"inputText\":\"Quick element\",\"outputText\":\"e\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>\n#include <string.h>\nint main()\n{\n  \tchar str[100], result;\n  \tint i, len;\n  \tint max = -1;\n   \tint freq[256] = {0}; \n   \tscanf(\"%[^\\n]s\",str);\n  \tlen = strlen(str);\n  \tfor(i = 0; i < len; i++)\n  \t{\n  \t\tfreq[str[i]]++;\n\t}\n  \tfor(i = 0; i < len; i++)\n  \t{\n\t\tif(max < freq[str[i]])\n\t\t{\n\t\t\tmax = freq[str[i]];\n\t\t\tresult = str[i];\n\t\t}\n\t}\n\t\n\tprintf(\"%c\", result);\n\treturn 0;\n}\n"},{"id":"test-tcs-5","title":"TCS-Ques-5","order":"0","problemStatement":"Write a program to find the equilibrium element in the given array.\nHint : A[i] is equilibrium element if A[0] + A[1] + \u2026 A[i-1] == A[i+1] + A[i+2] + \u2026 + A[n-1]\n","examples":"[{\"id\":\"1\",\"inputText\":\"6\\n1 2 3 4 3 3\",\"outputText\":\"4\"},{\"id\":\"2\",\"inputText\":\"7\\n1 2 3 4 4 5 6\",\"outputText\":\"No Equilibrium element found\"},{\"id\":\"3\",\"inputText\":\"5\\n1 3 5 2 2\",\"outputText\":\"5\"},{\"id\":\"4\",\"inputText\":\"6\\n10 5 3 1 5 10\",\"outputText\":\"No Equilibrium element found\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h> \nint findElement(int arr[], int n) \n{ \n\tint prefixSum[n]; \n\tprefixSum[0] = arr[0]; \n\tfor (int i = 1; i < n; i++) \n\t\tprefixSum[i] = prefixSum[i - 1] + arr[i]; \n\tint suffixSum[n]; \n\tsuffixSum[n - 1] = arr[n - 1]; \n\tfor (int i = n - 2; i >= 0; i--) \n\t\tsuffixSum[i] = suffixSum[i + 1] + arr[i]; \n\tfor (int i = 1; i < n - 1; i++) \n\t\tif (prefixSum[i] == suffixSum[i]) \n\t\t\treturn arr[i]; \n\treturn -1; \n} \n\nint main() \n{ \n\tint n;\n\tscanf(\"%d\",&n);\n\tint arr[n];\n\tfor(int i=0;i<n;i++)\n\t\tscanf(\"%d\",&arr[i]);\n\tint result = findElement(arr, n);\n\tif(result == -1)\n\t\tprintf(\"No Equilibrium element found\");\n\telse\n\t\tprintf(\"%d\",result); \n\treturn 0; \n} \n"},{"id":"test-tcs-6","title":"TCS-Ques-6","order":"0","problemStatement":"Write a program to create a dynamic array and insert an element in it, in the specified position.","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n1 2 3 4 5\\n2 10\",\"outputText\":\"1 10 2 3 4 5 \"},{\"id\":\"2\",\"inputText\":\"4\\n9 8 7 6\\n1\\n5\\n\",\"outputText\":\"5 9 8 7 6 \"},{\"id\":\"3\",\"inputText\":\"3\\n11 22 33\\n4\\n44\",\"outputText\":\"11 22 33 44 \"},{\"id\":\"4\",\"inputText\":\"1\\n100\\n1\\n50\\n\",\"outputText\":\"50 100 \"},{\"id\":\"5\",\"inputText\":\"5\\n1 2 3 4 5\\n3\\n10\",\"outputText\":\"1 2 10 3 4 5 \"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>\n#include<stdlib.h>\nint main()\n{\n    int *array, position, i, n, value;\n    scanf(\"%d\", &n);\n    array = (int*) malloc(n * sizeof(int));\n    if(array == NULL)                     \n    {\n        printf(\"Error! memory not allocated.\");\n        exit(0);\n    }\n    for(i = 0; i < n; ++i)\n    {\n        scanf(\"%d\", &array[i]);\n    }\n\tscanf(\"%d\", &position);\n    scanf(\"%d\", &value);\n\n      \tfor (i = n - 1; i >= position - 1; i--)    \n\t\tarray[i+1] = array[i];\n    \n\tarray[position-1] = value;\n    \n\tfor (i = 0; i <= n; i++)    \n\t\tprintf(\"%d \", array[i]);    \n    return 0;\n}\n\n    \n\t\n"},{"id":"test-tcs-7","title":"TCS-Ques-7","order":"0","problemStatement":"Write a program to create a dynamic array and print the first half sorted array in ascending order and second half in descending order.\n","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n1 2 3 4 5\\n\",\"outputText\":\"1 2 5 4 3 \"},{\"id\":\"2\",\"inputText\":\"6\\n1 2 3 4 4 7\\n\",\"outputText\":\"1 2 3 7 4 4 \"},{\"id\":\"3\",\"inputText\":\"3\\n1 2 3 \",\"outputText\":\"1 3 2\"},{\"id\":\"4\",\"inputText\":\"4\\n1 3 3 5\",\"outputText\":\"1 3 5 3\"},{\"id\":\"5\",\"inputText\":\"2\\n1 8\",\"outputText\":\"1 8\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"easy","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include<stdio.h>\n#include<stdlib.h>\nint main()\n{\n\tint *a,n,i,j,temp;\n\tscanf(\"%d\",&n);\n\ta=(int*)malloc(sizeof(int)*n);\n\tfor(i=0;i<n;i++)\n\t\tscanf(\"%d\",&a[i]);\n\tfor(i=0;i<n;i++)\n\t{\n\t\tfor(j=0;j<n-1;j++)\n\t\t{\n\t\t\tif(a[j]>a[j+1])\n\t\t\t{\n\t\t\t\ttemp=a[j];\n\t\t\t\ta[j]=a[j+1];\n\t\t\t\ta[j+1]=temp;\n\t\t\t}\n\t\t}\n\t}  \n\n  \tfor(i=0;i<n\/2;i++)\n\t{\n\t\tprintf(\"%d \",a[i]);\n\t}\n\tfor(i=n-1;i>=n\/2;i--)\n\t{\n\t\tprintf(\"%d \",a[i]);\n\t}\n\treturn 0;\n\t\t\t\t\n}\n\n"},{"id":"test-tcs-8","title":"TCS-Ques-8","order":"0","problemStatement":"Write a program to check the regular expression matching.\nHint : \u2018+\u2019 indicates consecutive multiple occurrence of that particular character.\n","examples":"[{\"id\":\"1\",\"inputText\":\"a+b+c\\naaabbc\\n\",\"outputText\":\"Matched\"},{\"id\":\"2\",\"inputText\":\"h+ello\\nhhiello\",\"outputText\":\"Not Matched\"},{\"id\":\"3\",\"inputText\":\"a+bc\\naaabc\",\"outputText\":\"Matched\"},{\"id\":\"4\",\"inputText\":\"c+t\\nct\\n\",\"outputText\":\"Matched\"},{\"id\":\"5\",\"inputText\":\"x+\\nxxxxx\\n\",\"outputText\":\"Matched\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include<stdio.h>\nint main()\n{\n\tchar arr[20],ans[20];\n\tint i=0,j=0,len;\n\tscanf(\"%s\",arr);\n\tscanf(\"%s\",ans);\n\tfor(len=0;arr[len]!='\\0';len++);\n\twhile(arr[i]==ans[j] && arr[i]!='\\0' )\n\t{\n\t\tif(arr[i+1]=='+')\n\t\t{\n\t\t\tfor( ; ans[j]==arr[i] ; j++);\n\t\t\ti=i+2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ti++;\n\t\t\tj++;\n\t\t}\n\t}\n\n  \tif(i>=len && ans[j]=='\\0')\n\t{\n\t\tprintf(\"Matched\");\n\t}\n\telse\n\t\tprintf(\"Not Matched\");\n\treturn 0;\n}\n\n"},{"id":"test-tcs-9","title":"TCS-Ques-9","order":"0","problemStatement":"Write a program to perform Alpha-Numeric Sorting.\n\nGiven text comprising of words and numbers, sort them both in ascending order and print them in a manner that a word is followed by a number. Words can be in upper or lower case. You have to convert them into lowercase and then sort and print them.\n\nConstraints: 1. Text starts with a word 2. Count of words and numbers are the same. 3. Duplicate elements are not allowed 4. Words should be printed in lower case. 5. No special characters allowed in text.\n","examples":"[{\"id\":\"1\",\"inputText\":\"2\\nSagar 35 sanjay 12 ganesH 53 ramesh 19\\nganesh 59 suresh 19 rakesh 26 laliT 96\\n\",\"outputText\":\"ganesh\\n12\\nramesh\\n19\\nsagar\\n35\\nsanjay\\n53\\nganesh\\n19\\nlalit\\n26\\nrakesh\\n59\\nsuresh\\n96\"},{\"id\":\"2\",\"inputText\":\"1\\nAlice 25 Bob 19 Charlie 32 David 18\",\"outputText\":\"alice\\n18\\nbob\\n19\\ncharlie\\n25\\ndavid\\n32\"},{\"id\":\"3\",\"inputText\":\"1\\nzara 10 mike 5 adam 20 brad 15\",\"outputText\":\"adam\\n5\\nbrad\\n10\\nmike\\n15\\nzara\\n20\"},{\"id\":\"4\",\"inputText\":\"1\\nJohn 45 Mike 30 Lisa 50 Adam 20\\n\",\"outputText\":\"adam\\n20\\njohn\\n30\\nlisa\\n45\\nmike\\n50\"},{\"id\":\"5\",\"inputText\":\"1\\nTom 40 Jerry 35 Bob 25 Alice 30\\n\",\"outputText\":\"alice\\n25\\nbob\\n30\\njerry\\n35\\ntom\\n40\\n\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"hard","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include <stdio.h>\n#include <string.h>\n#include<stdlib.h>\n#include<ctype.h>\nint main () \n{\n  char str[100],temp[20];\n  char name[10][8];\n  int number[10],i,j,k,p,q,t,n;\n  scanf(\"%d\",&n);\n  while(n--)\n  {\n  i=1,j=0,k=0;\n  scanf(\" %[^\\n]s\",&str);\n  while (str[j]) \n  {\n        str[j]=tolower(str[j]);\n        j++; \n  }\n  j=0;\n  char *s;\n  s = strtok (str,\" \");\n\n    while (s!= NULL)\n  {\n    if(!(i%2))\n    {\n        strcpy(temp,s);\n        number[j]=atoi(temp);\n        j++;\n    }\n    else\n    {\n        strcpy(name[k],s);\n        k++;\n    }\n    i++;\n    s = strtok (NULL, \" \"); \n  }\n \n\n    for (p = 0; p < j-1 ; p++)\n    {\n        for (q = p + 1; q < j; q++)\n        {\n            if (strcmp(name[p], name[q]) > 0)\n            {\n                strcpy(temp, name[p]);\n                strcpy(name[p], name[q]);\n                strcpy(name[q], temp);\n            }\n        }\n    }\n    for (p = 0; p < j-1 ; p++)\n    {\n        for (q = p + 1; q < j; q++)\n        {\n            if (number[p] > number[q])\n            {\n                t = number[p];\n                number[p] = number[q];\n                number[q] = t;\n            }\n\n           }  \n\t } \n    for(p=0;p<j;p++)\n    {\n        printf(\"\\n%s\",name[p]);\n        printf(\"\\n%d\",number[p]);\n        number[p]=0;\n    }\n    s=NULL;\n  }\n  return 0;\n}\n"},{"id":"test-tcs-10","title":"TCS-Ques-10","order":"0","problemStatement":"Write a program to print the given matrix elements in spiral order.\n","examples":"[{\"id\":\"1\",\"inputText\":\"3 3\\n1 2 3\\n4 5 6\\n7 8 9\\n\",\"outputText\":\"1 2 3 6 9 8 7 4 5 \"},{\"id\":\"2\",\"inputText\":\"4 4\\n1  2  3  4\\n5  6  7  8\\n9 10 11 12\\n13 14 15 16\\n\",\"outputText\":\"1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 \\n\"},{\"id\":\"3\",\"inputText\":\"3 4\\n1  2  3  4\\n5  6  7  8\\n9 10 11 12\\n\",\"outputText\":\"1 2 3 4 8 12 11 10 9 5 6 7\"},{\"id\":\"4\",\"inputText\":\"4 3\\n1  2  3\\n4  5  6\\n7  8  9\\n10 11 12\\n\",\"outputText\":\"1 2 3 6 9 12 11 10 7 4 5 8 \\n\"},{\"id\":\"5\",\"inputText\":\"5 5\\n1  2  3  4  5\\n6  7  8  9 10\\n11 12 13 14 15\\n16 17 18 19 20\\n21 22 23 24 25\\n\",\"outputText\":\"1 2 3 4 5 10 15 20 25 24 23 22 21 16 11 6 7 8 9 14 19 18 17 12 13 \\n\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include<stdio.h>\nvoid print_spirally(int row, int column);\n#define S 10\nint a[S][S];\nint main()\n{\n    int row, column;\n    scanf(\"%d %d\", &row, &column);\n    int i, j;\n    for(i=0; i<row; i++)\n    {\n        for(j=0; j<column; j++)\n        {\n            scanf(\"%d\", &a[i][j]);\n        }\n    }\n    \n    print_spirally(row, column);\n    \n    return 0;\n}\n\nvoid print_spirally(int row, int column)\n{\n  \tint i;\n  \tint r_min = 0, c_min = 0;\n    int r_max = row-1, c_max = column-1;\n    int total_elements_to_traverse = row * column;\n    int curr_traversed_count = 0;\n    while ((r_min <= r_max) && (c_min <= c_max) && (curr_traversed_count < \t\t\t\t\t\t\ttotal_elements_to_traverse))\n    {\n        for(i = c_min; (i <= c_max) && (curr_traversed_count < \t\t\t\t\t\t\t\t\ttotal_elements_to_traverse); i++)\n        {\n            printf(\"%d \", a[r_min][i]);\n            curr_traversed_count++;\n        }\n        for(i = r_min + 1; (i <= r_max) && (curr_traversed_count < \t\t\t\t\t\t\t\ttotal_elements_to_traverse); i++)\n        {\n            printf(\"%d \", a[i][c_max]);\n            curr_traversed_count++;\n        }\n\n       \t  for(i = c_max-1; (i >= c_min) && (curr_traversed_count < \t\t\t\t\t\t\t\t\ttotal_elements_to_traverse); i--)\n        {\n            printf(\"%d \", a[r_max][i]);\n            curr_traversed_count++;\n        }\n        for(i = r_max - 1; (i >= r_min+1) && (curr_traversed_count < \t\t\t\t\t\t\t\ttotal_elements_to_traverse); i--)\n        {\n            printf(\"%d \", a[i][c_min]);\n            curr_traversed_count++;\n        }\n        r_min++; c_min++; r_max--; c_max--;\n    }\n}\n"},{"id":"test-tcs-11","title":"TCS-Ques-11","order":"0","problemStatement":"Write a program to check for \u20180s\u2019, if found that corresponding row and column elements should become 0s and then finally print the resultant matrix.\n","examples":"[{\"id\":\"1\",\"inputText\":\"3 3\\n1 2 3\\n4 0 6\\n7 8 9\\n\",\"outputText\":\"1 0 3 \\n0 0 0 \\n7 0 9 \\n\"},{\"id\":\"2\",\"inputText\":\"3 4\\n5 1 3 4\\n7 8 0 6\\n9 0 2 1\\n\",\"outputText\":\"5 0 3 4 \\n7 0 0 6 \\n0 0 0 0 \\n\"},{\"id\":\"3\",\"inputText\":\"2 2\\n1 2\\n3 0\\n\",\"outputText\":\"1 0 \\n0 0 \"},{\"id\":\"4\",\"inputText\":\"2 3\\n0 0 0\\n0 0 0\",\"outputText\":\"0 0 0 \\n0 0 0 \"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include<stdio.h>\nint main()\n{\n\tint n,m,i,j,row,col;\n\tscanf(\"%d%d\",&n,&m);\n\tint a[n][m];\n\tfor(i=0;i<n;i++)\n\t{\n\t\tfor(j=0;j<m;j++)\n\t\t{\n\t\tscanf(\"%d\",&a[i][j]);\n\t\tif(a[i][j]==0)\n\t\t\t{\n\t\t\t\trow=i;\n\t\t\t\tcol=j;\n\t\t\t}\n\t\t}\n\t}\n\n  \tfor(i=0;i<n;i++)\n\t{\n\t\tfor(j=0;j<m;j++)\n\t\t{\n\t\t\tif(i==row||j==col)\n\t\t\ta[i][j]=0;\n\t\t}\n\t}\n\tfor(i=0;i<n;i++)\n\t{\n\t\tfor(j=0;j<m;j++)\n\t\t{\n\t\t\tprintf(\"%d \",a[i][j]);\t\n\t\t}\n\t\tprintf(\"\\n\");\t\n\t}\n}\n"},{"id":"test-tcs-12","title":"TCS-Ques-12","order":"0","problemStatement":"Write a program to find the maximum sum subsequence(increasing order) of the given array.\n","examples":"[{\"id\":\"1\",\"inputText\":\"5\\n1 2 8 0 9\\n\",\"outputText\":\"11\"},{\"id\":\"2\",\"inputText\":\"5\\n1 2 3 4 5\\n\",\"outputText\":\"15\"},{\"id\":\"3\",\"inputText\":\"6\\n1 2 5 3 4 10\\n\",\"outputText\":\"17\"},{\"id\":\"4\",\"inputText\":\"5\\n10 9 8 7 6\\n\",\"outputText\":\"10\"},{\"id\":\"5\",\"inputText\":\"7\\n5 6 7 1 2 8 9\\n\",\"outputText\":\"20\"}]","constraints":"No constraints","starterCode":"\/\/write your program here","category":"test","difficulty":"medium","blacklist":"[]","whitelist":"[]","imageUrl":"","answer":"#include<stdio.h>\nint sum_subsequence( int arr[], int n );\nint main()\n{\n    int N;\n    scanf(\"%d\", &N);\n    int arr[20], i, j;\n    for(i=0; i<N; i++)\n    {\n        scanf(\"%d\", &arr[i]);\n    }\n    printf(\"%d\", sum_subsequence( arr, N ) );\n    return 0;\n}\n\nint sum_subsequence( int arr[], int n )\n{\n      int running_sum, max_sum_sub, i;\n   \trunning_sum = arr[0];\n  \tmax_sum_sub = arr[0];\n  \tfor(i = 1; i < n; i++)\n      {\n      if(arr[i] > arr[i-1])\n        running_sum += arr[i];\n      else \n        running_sum = arr[i];     \n      if(running_sum > max_sum_sub)\n      {\n        max_sum_sub = running_sum;\n      }\n      }\n      return max_sum_sub;\n}\n"}]