{"id":"e1352d71-32b7-410c-a66e-1a0e30ad1ec5","name":"String With Difference Of Every Two Consecutive Characters","description":"1. You are given a string that contains only lowercase and uppercase alphabets. \r\n2. You have to form a string that contains the difference of ASCII values of every two consecutive characters between those characters.\r\n For \"abecd\", the answer should be \"a1b3e-2c1d\", as \r\n 'b'-'a' = 1\r\n 'e'-'b' = 3\r\n 'c'-'e' = -2\r\n 'd'-'c' = 1","inputFormat":"A String","outputFormat":"A String","constraints":"1 &lt;= length of string &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string.h>\n\nusing namespace std;\n\nvoid printstr(string str)\n{\n //write your code here\n}\nint main()\n{\n string str;\n getline(cin,str);\n printstr(str);\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static String solution(String str){\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tSystem.out.println(solution(str));\r\n\t}\r\n\r\n}"},"python":{"code":"def printstring(st):\n #write your code here\n\n\n\nst=input()\nprintstring(st)"}},"points":10,"difficulty":"easy","sampleInput":"pepCODinG","sampleOutput":"p-11e11p-45C12O-11D37i5n-39G","questionVideo":"https://www.youtube.com/embed/PHtNm0B9Ig4?end=99","hints":[],"associated":[{"id":"3f9537ee-dc77-4d10-aeff-09cda0f3accf","name":"What will be the output of given input?","slug":"what-will-be-the-output-of-given-input","type":4},{"id":"6e69a211-c5a4-4527-82af-fb9df933ec35","name":"Is this string valid ?","slug":"is-this-string-valid","type":4},{"id":"74f84b6e-67ea-4d39-8e0d-729b38921c74","name":"what will be the output of below string?","slug":"what-will-be-the-output-of-below-string","type":4},{"id":"c506d262-1017-4503-8700-b499914d48cb","name":"Can we solve this question using recursion?","slug":"can-we-solve-this-question-using-recursion","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"8e88c7cb-1b77-4dfa-ba1c-021c256a78b2","name":"String With Difference Of Every Two Consecutive Characters","slug":"string-with-difference-of-every-two-consecutive-characters","type":1}],"next":{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","type":1,"slug":"remove-primes"},"prev":{"id":"0ed3378e-43f8-4ea1-b5d6-ab09ea8397e6","name":"Toggle Optica Document","type":1,"slug":"toggle-optica-document"}}}

String With Difference Of Every Two Consecutive Characters

1. You are given a string that contains only lowercase and uppercase alphabets. 2. You have to form a string that contains the difference of ASCII values of every two consecutive characters between those characters. For "abecd", the answer should be "a1b3e-2c1d", as 'b'-'a' = 1 'e'-'b' = 3 'c'-'e' = -2 'd'-'c' = 1

{"id":"e1352d71-32b7-410c-a66e-1a0e30ad1ec5","name":"String With Difference Of Every Two Consecutive Characters","description":"1. You are given a string that contains only lowercase and uppercase alphabets. \r\n2. You have to form a string that contains the difference of ASCII values of every two consecutive characters between those characters.\r\n For \"abecd\", the answer should be \"a1b3e-2c1d\", as \r\n 'b'-'a' = 1\r\n 'e'-'b' = 3\r\n 'c'-'e' = -2\r\n 'd'-'c' = 1","inputFormat":"A String","outputFormat":"A String","constraints":"1 &lt;= length of string &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string.h>\n\nusing namespace std;\n\nvoid printstr(string str)\n{\n //write your code here\n}\nint main()\n{\n string str;\n getline(cin,str);\n printstr(str);\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static String solution(String str){\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tSystem.out.println(solution(str));\r\n\t}\r\n\r\n}"},"python":{"code":"def printstring(st):\n #write your code here\n\n\n\nst=input()\nprintstring(st)"}},"points":10,"difficulty":"easy","sampleInput":"pepCODinG","sampleOutput":"p-11e11p-45C12O-11D37i5n-39G","questionVideo":"https://www.youtube.com/embed/PHtNm0B9Ig4?end=99","hints":[],"associated":[{"id":"3f9537ee-dc77-4d10-aeff-09cda0f3accf","name":"What will be the output of given input?","slug":"what-will-be-the-output-of-given-input","type":4},{"id":"6e69a211-c5a4-4527-82af-fb9df933ec35","name":"Is this string valid ?","slug":"is-this-string-valid","type":4},{"id":"74f84b6e-67ea-4d39-8e0d-729b38921c74","name":"what will be the output of below string?","slug":"what-will-be-the-output-of-below-string","type":4},{"id":"c506d262-1017-4503-8700-b499914d48cb","name":"Can we solve this question using recursion?","slug":"can-we-solve-this-question-using-recursion","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"8e88c7cb-1b77-4dfa-ba1c-021c256a78b2","name":"String With Difference Of Every Two Consecutive Characters","slug":"string-with-difference-of-every-two-consecutive-characters","type":1}],"next":{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","type":1,"slug":"remove-primes"},"prev":{"id":"0ed3378e-43f8-4ea1-b5d6-ab09ea8397e6","name":"Toggle Optica Document","type":1,"slug":"toggle-optica-document"}}}
plane

Editor


Loading...

String With Difference Of Every Two Consecutive Characters

easy

1. You are given a string that contains only lowercase and uppercase alphabets. 2. You have to form a string that contains the difference of ASCII values of every two consecutive characters between those characters. For "abecd", the answer should be "a1b3e-2c1d", as 'b'-'a' = 1 'e'-'b' = 3 'c'-'e' = -2 'd'-'c' = 1

Constraints

1 <= length of string <= 1000

Format

Input

A String

Output

A String

Example

Sample Input

pepCODinG

Sample Output

p-11e11p-45C12O-11D37i5n-39G

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode