Question 1 How to Attempt? Revisit Later Find The Order Given two Strings input1 and input2 consisting of random alphabe
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Question 1 How to Attempt? Revisit Later Find The Order Given two Strings input1 and input2 consisting of random alphabe
Question 1 How to Attempt? Revisit Later Find The Order Given two Strings input1 and input2 consisting of random alphabets, find whether all the alphabets in input1 are in either increasing or decreasing order based on their ascii value. For example, input1="ACZa", its in increasing order. (65,67,90,97) input1="tbGB", its in decreasing order. (116,98,71,66) In case if input1 is not in either increasing or decreasing order, directly return Invalid After deciding input1 as increasing or decreasing; Consider input2 which consist of the same alphabets which are in input1, but the order of the alphabets may change. For example, input1="ACZa" input2="CAZa" here 'C' and 'A' are misplaced in input2, so the count of alphabets which are misplaced is 2 input1="tbGB" input2="tGBb" here 'G','B','b' are misplaced in input2. so the count of alphabets which are misplaced is 3 Expected output format: <Increasing or Decreasing>:count of alphabets which are misplaced in input2
alphabets which are misplaced in inputz Example-1 input1: ACZa input2: CAZA output: Increasing:2 Example-2 input1: tbGB input2: tGBb output: Decreasing:3 Example-3 input1: ILkQwfg input2: QwlLkfg output: Invalid Explanation: The alphabets in input1 are not in either increasi decreasing order. Note: 1. input1 and input2 will be of same length. 2. input1 and input2 will contain unique alphabets in them. 3. 'B' and 'b' are considered as different alphabets because their values are different.