1 00:00:01,710 --> 00:00:02,400 Hi, everyone. 2 00:00:02,430 --> 00:00:05,990 So today we are going to solve this problem, evaluate expression. 3 00:00:06,570 --> 00:00:09,220 OK, so the problem statement is very simple. 4 00:00:09,240 --> 00:00:12,000 So this is basically that prop string. 5 00:00:13,070 --> 00:00:20,880 So this is a very interesting so this will be our input and we have to evaluate our postfix notation. 6 00:00:21,110 --> 00:00:24,050 OK, so there are basically two types of annotations. 7 00:00:24,050 --> 00:00:25,910 So we have three notations. 8 00:00:28,560 --> 00:00:30,720 So these notations are infix. 9 00:00:33,270 --> 00:00:34,650 We have postfix. 10 00:00:36,490 --> 00:00:38,140 And we have prefix notation. 11 00:00:39,530 --> 00:00:47,120 OK, so generally we are only aware of infix notation, so infix means basically two plus one. 12 00:00:48,310 --> 00:00:51,680 Multiple-entry, so this is an example of infix notation. 13 00:00:51,920 --> 00:00:54,820 OK, but there are postfix and prefix notation. 14 00:00:54,970 --> 00:00:55,880 So what happens? 15 00:00:55,900 --> 00:01:01,780 So if you will give this input to the calculator, so, for example, if you will give this input to 16 00:01:01,780 --> 00:01:04,900 the calculator, then how the calculator will evaluate our answer. 17 00:01:05,200 --> 00:01:12,490 So first of all, Calculator will convert this infix expression into postfix and then postfix expression 18 00:01:12,490 --> 00:01:15,820 is evaluated and then we will get our answer. 19 00:01:16,150 --> 00:01:18,490 OK, so that's how the calculator works. 20 00:01:18,770 --> 00:01:22,570 So Calculator, the working of calculator is very simple. 21 00:01:23,020 --> 00:01:29,080 First of all, the first step is to convert the infix expression into the postfix. 22 00:01:31,260 --> 00:01:35,190 And then evaluate the postfix expression. 23 00:01:35,250 --> 00:01:41,400 OK, so evaluate postfix expression so they'll tell the calculator works. 24 00:01:41,640 --> 00:01:44,640 So basically we are given postfix expression. 25 00:01:44,640 --> 00:01:46,380 So this is a postfix. 26 00:01:48,440 --> 00:01:53,090 Expression and we have to evaluate this, OK, so we have to evaluate this. 27 00:01:54,290 --> 00:01:59,030 So the other name of this question can be evaluated, postfix expression. 28 00:02:00,520 --> 00:02:05,290 The other name of postfix expression is also called reverse Polish notation. 29 00:02:05,470 --> 00:02:09,250 OK, so reverse Polish notation. 30 00:02:10,350 --> 00:02:12,640 This is the name of Postfix. 31 00:02:13,330 --> 00:02:17,380 OK, so basically how we can convert infix to postfix. 32 00:02:17,600 --> 00:02:18,790 So this is very simple. 33 00:02:19,000 --> 00:02:24,420 OK, so this is given postfix expression and this is basically its corresponding infix. 34 00:02:25,270 --> 00:02:27,680 So this is infix and this we already know. 35 00:02:27,700 --> 00:02:34,330 Similarly, this is infix and we are very familiar with the infix views and fixing our day to day life 36 00:02:34,570 --> 00:02:37,690 so how we can convert infix into postfix. 37 00:02:38,110 --> 00:02:44,100 OK, so for example, let us consider infix expression, so let us consider this one only. 38 00:02:44,260 --> 00:02:46,410 So let's take it today. 39 00:02:46,600 --> 00:02:48,370 OK, so this is a very good example. 40 00:02:49,150 --> 00:02:50,320 So this is infix. 41 00:02:51,920 --> 00:02:56,260 Now, how we can convert infix to postfix, so the idea is very simple, what we will do. 42 00:02:56,720 --> 00:02:59,200 So first of all, move the opponent. 43 00:02:59,210 --> 00:03:01,070 So we have operators. 44 00:03:02,430 --> 00:03:03,780 And we have operands. 45 00:03:05,200 --> 00:03:09,410 So operators means plus, multiply, minus and divide. 46 00:03:09,480 --> 00:03:12,190 OK, plus or minus divide and so on. 47 00:03:12,380 --> 00:03:17,480 OK, and operators are basically indigence on which we have to perform the opera operations. 48 00:03:17,500 --> 00:03:22,540 OK, so what will do, move the operators to the closing brackets. 49 00:03:23,710 --> 00:03:24,610 So similarly. 50 00:03:25,660 --> 00:03:27,940 Fort Bliss, this is the closing record. 51 00:03:29,470 --> 00:03:35,650 OK, so remove, multiply, remove, divide from here and put it here similarly, remove place from 52 00:03:35,650 --> 00:03:37,250 here and put glass here. 53 00:03:37,480 --> 00:03:39,530 Now read this from left to right. 54 00:03:39,730 --> 00:03:41,240 So first of all, we have four. 55 00:03:41,650 --> 00:03:43,480 So we will write for then. 56 00:03:43,480 --> 00:03:49,510 Plus is not here because it is here, then we will not read the opening record. 57 00:03:49,510 --> 00:03:50,640 So we will read 13. 58 00:03:50,890 --> 00:03:53,080 So I will read 13. 59 00:03:53,380 --> 00:03:55,100 Then the divide is not there. 60 00:03:55,150 --> 00:03:55,960 We have five. 61 00:03:55,990 --> 00:03:57,320 So I will write five. 62 00:03:57,610 --> 00:03:59,170 Then we have this multiply. 63 00:03:59,190 --> 00:04:00,060 So remove this. 64 00:04:00,340 --> 00:04:01,630 So we have divide. 65 00:04:01,630 --> 00:04:02,010 Sorry. 66 00:04:02,020 --> 00:04:03,940 So I will write divide then. 67 00:04:03,940 --> 00:04:06,440 At this point I have plus so I will write plus. 68 00:04:06,730 --> 00:04:07,960 So this is basically. 69 00:04:09,010 --> 00:04:10,300 The postfix notation. 70 00:04:10,660 --> 00:04:12,740 OK, so this is a postfix notation. 71 00:04:12,760 --> 00:04:14,110 Let us take one more example. 72 00:04:14,530 --> 00:04:17,680 OK, so suppose I have let's say. 73 00:04:18,850 --> 00:04:20,410 Two plus one. 74 00:04:21,940 --> 00:04:23,770 And two, three. 75 00:04:24,030 --> 00:04:32,250 OK, so this is basically infix and we have to convert this into postfix so how we can do this. 76 00:04:32,260 --> 00:04:36,150 So the idea is very simple, but we have to do we have to move the operators. 77 00:04:36,370 --> 00:04:38,860 So for plus it's closing bracket. 78 00:04:38,860 --> 00:04:40,810 Is this so right. 79 00:04:40,810 --> 00:04:41,470 Plus here. 80 00:04:42,740 --> 00:04:44,120 Again, remove it from here. 81 00:04:45,240 --> 00:04:47,350 So for multiply, it's closing record. 82 00:04:47,370 --> 00:04:48,930 Is this OK? 83 00:04:48,990 --> 00:04:55,390 So remove, multiply from here and right, multiply here and then read from left to right. 84 00:04:55,890 --> 00:04:57,720 So first I have this to you. 85 00:04:57,720 --> 00:05:00,980 Do not consider this opening and closing brackets. 86 00:05:00,990 --> 00:05:02,400 OK, so first I have to. 87 00:05:02,790 --> 00:05:07,940 So I will write to then Plus's naughtier then I have one so I will write one. 88 00:05:08,280 --> 00:05:14,220 Then I have Pless so I will write plus then I have three so I will write three. 89 00:05:14,440 --> 00:05:17,160 Then I have multiply so I will write multiply. 90 00:05:18,030 --> 00:05:22,610 OK, so this is the corresponding postfix notation you can see in the above example. 91 00:05:22,650 --> 00:05:25,140 Also saw two one plus three multiply. 92 00:05:26,480 --> 00:05:29,750 OK, so do one blessed three multiply. 93 00:05:30,110 --> 00:05:35,460 OK, so the input is given a postfix expression and we have to evaluate. 94 00:05:35,660 --> 00:05:40,070 So basically if the expression was infix, we can see our answer will be nine. 95 00:05:40,080 --> 00:05:41,300 We can easily calculate. 96 00:05:41,330 --> 00:05:44,060 OK, so in this case, our answer will be six. 97 00:05:44,450 --> 00:05:46,460 So this is an integer division. 98 00:05:46,640 --> 00:05:50,000 So whenever integer upon integer we will get integer only. 99 00:05:50,210 --> 00:05:51,610 So this is basically two. 100 00:05:51,620 --> 00:05:53,810 We will get two and four plus two is six. 101 00:05:54,680 --> 00:05:59,640 OK, so now let's see how to evaluate postfix expression. 102 00:05:59,660 --> 00:06:05,510 So basically there are some rules on how to evaluate for expression and we will simply follow the rules. 103 00:06:05,540 --> 00:06:08,600 OK, if you don't know the rules, you cannot solve this question. 104 00:06:09,070 --> 00:06:12,230 OK, so there are basically defined rules. 105 00:06:13,650 --> 00:06:15,540 To solve the postfix expression. 106 00:06:15,830 --> 00:06:20,880 OK, and you have to remember this rules, OK, if you don't know the rules, you can resolve this question. 107 00:06:22,060 --> 00:06:27,100 OK, so the rules are very simple, so let us consider an example first. 108 00:06:27,170 --> 00:06:31,910 So the first two and one plus three and multiply. 109 00:06:31,960 --> 00:06:34,230 So this is a postfix notation. 110 00:06:34,540 --> 00:06:36,190 So the rules are very, very simple. 111 00:06:36,340 --> 00:06:37,760 OK, so what are the rules? 112 00:06:38,080 --> 00:06:40,690 So obviously, I will have operators. 113 00:06:42,540 --> 00:06:44,040 And I will have opening's. 114 00:06:45,520 --> 00:06:49,930 So operators will be like plus minus multiply and divide. 115 00:06:50,080 --> 00:06:54,340 OK, so for operators to work, I should have two options. 116 00:06:55,480 --> 00:07:00,700 I'll get to should be able to be for example, you can only use plus when I have to options E plus B 117 00:07:01,360 --> 00:07:04,850 minus B, E multiplier baby and a divided baby. 118 00:07:04,900 --> 00:07:07,000 OK, so we need to operands. 119 00:07:08,780 --> 00:07:10,020 To apply the operators. 120 00:07:10,190 --> 00:07:16,820 OK, so the idea is very simple, maintain a stake so you have a stake in the stake is empty. 121 00:07:17,000 --> 00:07:18,770 So you are standing at this point. 122 00:07:19,850 --> 00:07:26,900 So if it is an open end, so if it is to then push, this is open push. 123 00:07:27,860 --> 00:07:32,150 Now I have an operator, so I have operator. 124 00:07:32,390 --> 00:07:34,100 So I have to perform operation. 125 00:07:34,370 --> 00:07:36,310 OK, so we're performing the operation. 126 00:07:36,320 --> 00:07:41,810 What I will do, I will pop one, I will pop two and I will do the operation. 127 00:07:41,810 --> 00:07:43,880 So I will do two plus one. 128 00:07:44,120 --> 00:07:45,390 OK, I am writing it here. 129 00:07:45,590 --> 00:07:47,140 So at this point what will happen? 130 00:07:47,150 --> 00:07:51,320 I will pop the top two element of the stack and I will do the operation. 131 00:07:51,320 --> 00:07:53,450 So I will write two plus one. 132 00:07:54,540 --> 00:07:59,490 OK, so at this point, what I am doing pop the two elements. 133 00:08:00,930 --> 00:08:08,760 So that we can apply the plus operating between them, so pop, two elements apply plus operator, so 134 00:08:08,760 --> 00:08:15,480 after playing the plus operators, so we will get the result three and then put Bush result three inside 135 00:08:15,480 --> 00:08:17,260 the stick Bush result. 136 00:08:17,280 --> 00:08:18,370 So the result is three. 137 00:08:18,420 --> 00:08:20,180 So what we will do, we will push the result. 138 00:08:20,460 --> 00:08:22,130 So three will come inside the stack. 139 00:08:22,830 --> 00:08:23,190 OK. 140 00:08:24,170 --> 00:08:31,880 Now, again, so I have an option, if it is an option, you can basically push, OK, now I have an 141 00:08:31,880 --> 00:08:36,470 operator, so if it is an operator, what we have to do, we have to pop two elements. 142 00:08:36,500 --> 00:08:40,250 So simply follow the step up, two elements. 143 00:08:40,610 --> 00:08:42,730 So two elements are three and three. 144 00:08:43,220 --> 00:08:46,280 So the two elements are three and three. 145 00:08:46,310 --> 00:08:48,630 Then what I have to do, I have to apply the operator. 146 00:08:48,830 --> 00:08:51,420 So in this case, our operators multiply. 147 00:08:51,620 --> 00:08:53,900 So we will apply the operator. 148 00:08:55,320 --> 00:08:58,950 We will get the result and result will be nine and then we have to push the result. 149 00:08:59,210 --> 00:09:01,740 OK, so basically these two elements are public. 150 00:09:02,040 --> 00:09:03,270 I have to push the result. 151 00:09:03,420 --> 00:09:07,710 So I will push the result nine and then I will reach at the end. 152 00:09:07,920 --> 00:09:09,810 OK, so what will be our answer? 153 00:09:09,840 --> 00:09:15,810 So finally, our answer will be the element present at this Dec. 11 percent detail of the strike. 154 00:09:16,050 --> 00:09:21,510 So stack as dot, dot, dot, dot, dot will be our answer. 155 00:09:21,540 --> 00:09:22,950 So our answer is nine. 156 00:09:23,410 --> 00:09:27,150 OK, let's see so we can see. 157 00:09:27,330 --> 00:09:29,580 Our answer is nine. 158 00:09:30,230 --> 00:09:31,560 OK, now let us. 159 00:09:32,580 --> 00:09:36,090 Used the same approach on this for three, four, 13, five. 160 00:09:37,110 --> 00:09:40,110 Divide and class, OK, 48 in five divided plus. 161 00:09:43,730 --> 00:09:49,430 So I have four, 13, five divide plus. 162 00:09:50,660 --> 00:09:52,340 So we know the rules are very simple. 163 00:09:53,960 --> 00:09:56,500 If it is an integer, push inside the stick. 164 00:09:56,580 --> 00:09:59,150 OK, so at this point, what will happen? 165 00:09:59,180 --> 00:10:06,530 So this is an integer, which we have integer, which we have integer. 166 00:10:07,630 --> 00:10:14,110 Bush, we have an op ed, so if it is an operator, obviously we need to eliminate, so we need to eliminate. 167 00:10:14,140 --> 00:10:18,190 So how we will get to elements, we will get the two elements with the help of Steck. 168 00:10:18,520 --> 00:10:22,590 So with the help of Steg, I will Bob Fife and I will pop 13. 169 00:10:22,620 --> 00:10:24,280 OK, so remove five and 13. 170 00:10:25,060 --> 00:10:27,730 So I have to eliminate 13 and five. 171 00:10:28,300 --> 00:10:31,090 And then obviously we have to apply the operator. 172 00:10:31,360 --> 00:10:34,420 So applied the operator after applying the operator. 173 00:10:34,420 --> 00:10:37,080 Our result will be 13 by five, which is two. 174 00:10:37,530 --> 00:10:39,180 OK, so this is our result. 175 00:10:39,190 --> 00:10:42,760 And now what we have to do, we have to push that result inside the stack. 176 00:10:43,030 --> 00:10:44,380 So too will come here. 177 00:10:45,720 --> 00:10:53,640 OK, now, again, move ahead, so I have basically plus so plus that means we need two elements. 178 00:10:55,390 --> 00:11:00,670 OK, and how we will get there to eliminate simply we will take the two elements from the top of the 179 00:11:00,670 --> 00:11:03,090 stack, so remove two and remove four. 180 00:11:03,490 --> 00:11:05,680 So I have four and I have two. 181 00:11:06,070 --> 00:11:09,340 And then what we have to do, we have to apply the operator operators. 182 00:11:09,340 --> 00:11:10,750 So we will apply the operator. 183 00:11:11,160 --> 00:11:16,810 Our result will come out to be six and then we would have to do we have to push the result inside the 184 00:11:16,810 --> 00:11:17,210 stack. 185 00:11:17,710 --> 00:11:20,320 OK, and then I will reach at the end. 186 00:11:20,470 --> 00:11:22,970 So after reaching the end, what will be our answer? 187 00:11:23,140 --> 00:11:26,980 Our answer is basically the top element of the stack, which is six. 188 00:11:27,250 --> 00:11:30,550 OK, so for this case, our output is six and we can see here. 189 00:11:31,810 --> 00:11:33,220 Our output was six. 190 00:11:33,270 --> 00:11:38,320 OK, so basically our goal is working, our logic is 100 percent correct. 191 00:11:39,020 --> 00:11:41,480 OK, now you can assume here. 192 00:11:41,650 --> 00:11:44,680 OK, so you can assume that. 193 00:11:46,630 --> 00:11:53,230 What we can assume, so the input given to us, they input postfix expression given to us is basically 194 00:11:53,230 --> 00:11:54,230 a valid expression. 195 00:11:54,250 --> 00:11:57,460 OK, this is a valid expression that we can assume. 196 00:11:58,690 --> 00:12:00,890 OK, so now let us write the code. 197 00:12:01,150 --> 00:12:03,160 So basically the rules are very simple. 198 00:12:04,440 --> 00:12:07,420 So no one, if it is an open. 199 00:12:08,990 --> 00:12:10,970 If operand, then simply push. 200 00:12:12,010 --> 00:12:13,960 Second guess it is operator. 201 00:12:15,060 --> 00:12:21,390 So if it is operator, then it is very simple, you need two elements to perform the operation and how 202 00:12:21,390 --> 00:12:24,120 you will get to elements simply the top of this track. 203 00:12:24,990 --> 00:12:25,440 OK. 204 00:12:26,620 --> 00:12:33,130 Perform the operation, we will perform plus, minus multiply, divide, so plus minus, multiply and 205 00:12:33,130 --> 00:12:35,600 divide and then you will get the result. 206 00:12:35,770 --> 00:12:38,460 So Bush that is held inside this deck. 207 00:12:39,620 --> 00:12:46,040 And finally, what will happen is finally our answer basically will be the element, there will be only 208 00:12:46,040 --> 00:12:47,300 one element at the end. 209 00:12:47,350 --> 00:12:54,470 OK, so at the end there will be only one element inside the stack and that element will be our answer. 210 00:12:54,530 --> 00:12:57,860 OK, there will be only one element at the end and it will be our answer. 211 00:12:58,050 --> 00:13:01,520 So that is basically the last remaining element of the stack. 212 00:13:01,520 --> 00:13:05,030 And we can get that element with the help of the top. 213 00:13:05,980 --> 00:13:08,140 OK, now let us read the gold. 214 00:13:11,050 --> 00:13:15,530 So if you have understood the solution, if you understood the logic, writing code is very easy. 215 00:13:15,880 --> 00:13:22,360 So first of all, what we need, we need a stack and stack of integers, basically, OK, we are storing 216 00:13:22,360 --> 00:13:23,640 and beta inside the stack. 217 00:13:24,550 --> 00:13:26,610 So the name of the stack is empty. 218 00:13:26,710 --> 00:13:29,820 Now, if we have to do, we are simply iterating. 219 00:13:29,950 --> 00:13:31,060 So let us separate. 220 00:13:31,060 --> 00:13:34,000 So equal zero I listin. 221 00:13:34,980 --> 00:13:36,960 Tokens, Dot says. 222 00:13:38,420 --> 00:13:45,230 And I placeless, so we are trading OK, now what we have to do so. 223 00:13:46,560 --> 00:13:54,300 If the top element is an apprentice, we will push and if it is appropriate, so if it is an operator. 224 00:13:54,330 --> 00:14:03,650 So basically if tokens of a equal equal plus or tokens of a 225 00:14:06,360 --> 00:14:18,120 minus or tokens of a equal equal multiply or tokens of a ecological divide. 226 00:14:23,170 --> 00:14:27,820 So if this is the scenario, then what we have to do, so if it is the operator, we have to push, 227 00:14:27,820 --> 00:14:33,040 we have to pop two elements, OK, so we need two elements here to perform the operation. 228 00:14:36,060 --> 00:14:37,380 We need two elements. 229 00:14:37,540 --> 00:14:43,710 OK, so now let's get both the elements and we will get the elements from the stack, so let's name 230 00:14:43,710 --> 00:14:47,220 it value one, which is a start top. 231 00:14:51,050 --> 00:14:52,190 And astronaut Bob. 232 00:14:54,830 --> 00:15:02,150 Now, let us get our second value, our second element, so we do again our top, an astronaut, Bob 233 00:15:02,150 --> 00:15:02,630 Stegner. 234 00:15:02,630 --> 00:15:03,680 Double standard. 235 00:15:03,800 --> 00:15:04,850 Double standard, Bob. 236 00:15:09,080 --> 00:15:14,870 OK, so we have our board, the elements now, let us perform the operation, so if. 237 00:15:17,410 --> 00:15:26,980 Tokens of equal, equal, plus, then what we have to do, we will add we want and we do OK so as to 238 00:15:26,980 --> 00:15:30,580 not so first find the result and then push. 239 00:15:31,510 --> 00:15:34,090 So I have to do with two plus one. 240 00:15:34,300 --> 00:15:36,210 OK, I am finding the result. 241 00:15:36,790 --> 00:15:39,520 So Bush result inside the deck. 242 00:15:41,070 --> 00:15:43,500 OK, so push the result inside stick. 243 00:15:47,440 --> 00:15:48,310 Now, similarly. 244 00:15:57,050 --> 00:15:58,100 So elusive. 245 00:15:59,150 --> 00:16:05,480 If tokens of A is minus, we have separate operations, so I will do we do minus Reven. 246 00:16:06,490 --> 00:16:07,240 Similarly. 247 00:16:09,070 --> 00:16:11,200 And if I have multiply operation. 248 00:16:13,970 --> 00:16:20,270 I will do over to multiply one, and if I have the divide operation. 249 00:16:23,370 --> 00:16:25,670 So I will do we do divided by one. 250 00:16:26,390 --> 00:16:29,070 OK, and that's all now. 251 00:16:30,080 --> 00:16:33,590 Now, in the Elzbieta, what we have, so we have options here. 252 00:16:34,950 --> 00:16:39,530 Now, we discussed if we have an option, we can basically push inside the stack. 253 00:16:39,780 --> 00:16:45,510 So what I will write is to not push and we can basically push Dawkins off a. 254 00:16:46,850 --> 00:16:49,370 But there's a problem here and what is the problem? 255 00:16:51,310 --> 00:16:53,470 So first of all, this will be Bush. 256 00:16:58,580 --> 00:16:59,600 So what is the problem? 257 00:17:00,650 --> 00:17:03,600 So basically this bag is often details. 258 00:17:03,620 --> 00:17:08,880 OK, so I have created a stack of often teachers and tokens of I is basically a string. 259 00:17:09,410 --> 00:17:15,920 OK, so it is basically a string, for example, tartine, for example, to five, for example, to 260 00:17:16,250 --> 00:17:22,069 OK, so this is basically a string and our stack, our stack is of integers. 261 00:17:22,680 --> 00:17:27,780 So what I have to do, I have to convert the string into integers. 262 00:17:28,099 --> 00:17:29,810 OK, so this is our problem. 263 00:17:29,810 --> 00:17:35,000 I have to convert the string into integers so that I can push integer inside the deck. 264 00:17:36,010 --> 00:17:39,620 OK, so basically we do not have to write code for this. 265 00:17:39,620 --> 00:17:47,930 We have inbuilt function and the name of the function is to say, OK, so what it does, it will take 266 00:17:47,930 --> 00:17:49,100 a string as input. 267 00:17:50,490 --> 00:17:53,850 And it will give me the integer as output. 268 00:17:54,030 --> 00:18:01,750 OK, so if I will give it away basically a string, let's say 45, then it will give me integer 45. 269 00:18:01,770 --> 00:18:04,930 OK, so that is the functionality of it to wavefunction. 270 00:18:04,980 --> 00:18:10,590 OK, so this function is present inside the inside some library of C++. 271 00:18:10,620 --> 00:18:13,530 OK, so this function is already implemented. 272 00:18:13,560 --> 00:18:19,500 We do not have to implement this, but there is a problem with this, a two way function and what is 273 00:18:19,500 --> 00:18:20,020 the problem. 274 00:18:20,340 --> 00:18:22,360 So the problem is basically very simple. 275 00:18:22,680 --> 00:18:24,720 So I'm explaining it here. 276 00:18:27,520 --> 00:18:35,260 So first thing you understand that why we have to convert string into integer, because our input, 277 00:18:35,770 --> 00:18:41,740 the input that is given to us is basically a string and the stack that we have created is basically 278 00:18:41,740 --> 00:18:42,600 often tedious. 279 00:18:42,610 --> 00:18:44,920 So that's why I have to convert a string in 2010. 280 00:18:45,160 --> 00:18:48,150 OK, now the second thing, how to convert into integer. 281 00:18:48,160 --> 00:18:53,890 So I'm telling you, we have a function in the way I will give a string as input and it will give me 282 00:18:53,890 --> 00:18:54,810 the integer value. 283 00:18:55,300 --> 00:19:03,290 Simple, but there's again a problem with a two way function and the problem with it is so in C++ there 284 00:19:03,310 --> 00:19:04,990 is basically two types of string. 285 00:19:06,280 --> 00:19:12,670 OK, so there are two types of strings, so first one is the C strange string C style. 286 00:19:14,140 --> 00:19:15,750 So this is basically the character. 287 00:19:16,910 --> 00:19:17,350 OK. 288 00:19:17,800 --> 00:19:20,260 And the second one is basically the string class. 289 00:19:22,520 --> 00:19:24,170 OK, so this is. 290 00:19:25,310 --> 00:19:26,990 This is basically distinctness. 291 00:19:28,480 --> 00:19:34,930 And it wavefunction takes in Putsy style strength and not this C++ type string. 292 00:19:34,960 --> 00:19:40,550 OK, so what I have to do, so I have to convert this string in to see Strela string. 293 00:19:41,050 --> 00:19:45,900 OK, so basically I am repeating myself in C++ we have two types of string. 294 00:19:46,180 --> 00:19:50,200 So first one is this e-mail and the second one is basically the string class. 295 00:19:50,580 --> 00:19:53,050 OK, so here I will write string as. 296 00:19:55,100 --> 00:20:02,260 And this is the character, Mary, so it wavefunction takes input, see style string, basically correct 297 00:20:02,550 --> 00:20:03,320 type string. 298 00:20:03,800 --> 00:20:08,390 And the input which is given to us is basically the second by posting. 299 00:20:08,750 --> 00:20:14,960 So there should be a way to convert this string and do this character, Eddie, and for converting. 300 00:20:15,410 --> 00:20:19,580 So we have a function called Dot C and a score SDR. 301 00:20:20,790 --> 00:20:25,660 OK, so this is the function which is used to convert this type of string into the correct. 302 00:20:26,370 --> 00:20:29,100 So what I will write, I will write you to away. 303 00:20:30,080 --> 00:20:38,510 I have the input, which is this tape and what I will do, I will write, not see and the score SDR. 304 00:20:40,430 --> 00:20:42,460 OK, so that's how it will work. 305 00:20:44,010 --> 00:20:50,870 OK, so this string is basically this is a token of a token of fire is basically a string. 306 00:20:51,630 --> 00:20:53,040 Now, let us write the code. 307 00:20:57,260 --> 00:20:59,890 So I cannot write like this sort of. 308 00:21:00,170 --> 00:21:08,690 This is basically a string, so for converting string into integer, I have to use it to wavefunction. 309 00:21:10,430 --> 00:21:17,440 But this is not enough, not enough, because it's wavefunction will give us added that this dog that 310 00:21:17,780 --> 00:21:19,900 they did expect a sea style sting. 311 00:21:20,270 --> 00:21:26,810 So what I have to do, I have to use dot see in the square star so that ci a. could steer. 312 00:21:28,580 --> 00:21:30,560 So all these functions are in functions. 313 00:21:30,590 --> 00:21:36,980 OK, you do not have to worry about this, and if your doubt is how I know about these functions is 314 00:21:36,980 --> 00:21:42,110 basically at this point when I first of all, this question, at this point, I get confused how to 315 00:21:42,110 --> 00:21:42,490 solve. 316 00:21:42,500 --> 00:21:45,830 Then I search on the Internet and I came up with the solutions. 317 00:21:45,860 --> 00:21:47,900 OK, so that's how everyone learns. 318 00:21:49,820 --> 00:21:52,900 So finally, when I will come out of this loop. 319 00:21:52,910 --> 00:21:53,990 So what will happen? 320 00:21:56,820 --> 00:21:58,170 So this is Ms. 321 00:22:03,400 --> 00:22:09,090 OK, so when I will come out of this loop, so basically I will have only one element inside the stick, 322 00:22:09,400 --> 00:22:13,200 so only one element inside the stick, and that will be our answer. 323 00:22:15,540 --> 00:22:20,840 So let us return our answer so we're done Steck, dot, dot. 324 00:22:21,630 --> 00:22:25,010 OK, you can see the return type of the function is in Pejar. 325 00:22:25,290 --> 00:22:27,630 That's why I have created this stack of integers. 326 00:22:27,640 --> 00:22:30,420 OK, so finally I can write like this. 327 00:22:30,420 --> 00:22:31,710 They don't stack up. 328 00:22:32,400 --> 00:22:35,220 So I think I have done everything correctly. 329 00:22:35,940 --> 00:22:37,560 Now let us try to run our code. 330 00:22:40,940 --> 00:22:43,460 OK, so there is some problem with the Blackwood's. 331 00:23:00,000 --> 00:23:02,060 OK, so there will be one more Beckert. 332 00:23:06,850 --> 00:23:08,200 Not at a summit, our called. 333 00:23:10,350 --> 00:23:15,000 OK, so our goal is working fine, so what is the time and the space complexity? 334 00:23:16,020 --> 00:23:22,350 OK, so basically the time complexity, we are just getting over the edge over the strings of time. 335 00:23:22,350 --> 00:23:25,860 Complexity is on and we are using we are creating a stack. 336 00:23:26,200 --> 00:23:32,040 So the space complexities on OK, so this is the time and the space complexity of a solution. 337 00:23:33,610 --> 00:23:36,010 OK, so I hope you understood this. 338 00:23:37,270 --> 00:23:39,950 I hope you understood this problem and also the solution. 339 00:23:40,180 --> 00:23:43,450 So basically you can see reverse policy notation. 340 00:23:43,480 --> 00:23:48,770 OK, so this is the another name for postfix rotation policy expression. 341 00:23:48,820 --> 00:23:55,360 OK, so if you have any doubt in this problem, it everyday approach or either with the or you can ask 342 00:23:55,360 --> 00:23:55,630 me. 343 00:23:55,730 --> 00:23:57,280 OK, thank you.