Showing posts with label Final Destination Hacker Earth Solution in C. Show all posts
Showing posts with label Final Destination Hacker Earth Solution in C. Show all posts

Monday, 31 August 2020

Final Destination Hacker Earth Solution in C

 https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/final-destination-cakewalk/submissions/


#include<stdio.h>
#include<string.h>
int main()
{
char str[1000000];
scanf(" %s", str);
    int i,x=0,y=0;
    for(i=0;str[i]!='\0';i++)
{
if(str[i] == 'L')
x=x-1;
if(str[i] == 'D')
y=y-1;
if(str[i] == 'R')
x=x+1;
if(str[i] == 'U')
y=y+1;
}
printf("%d %d",x,y);
}