1 00:00:01,020 --> 00:00:01,710 Hi, everyone. 2 00:00:01,740 --> 00:00:05,460 So today we are going to solve this question Excel sheet column no. 3 00:00:05,730 --> 00:00:07,380 OK, so what is the question? 4 00:00:07,410 --> 00:00:08,670 So question is very simple. 5 00:00:08,700 --> 00:00:13,830 Basically, we will be provided with the column title as it's appeared in the Excel sheet and we have 6 00:00:13,830 --> 00:00:15,870 to find the corresponding column number. 7 00:00:16,490 --> 00:00:20,610 OK, so basically the input will be a string. 8 00:00:21,480 --> 00:00:26,600 And this string is basically the column title and it will contain all uppercase alphabets. 9 00:00:26,700 --> 00:00:29,700 OK, it will contain all uppercase alphabet. 10 00:00:30,770 --> 00:00:36,050 And what we have to do, so basically we have to find its corresponding number. 11 00:00:36,090 --> 00:00:41,750 Let us take some example to understand, OK, for example, this is the column title, then the column 12 00:00:41,750 --> 00:00:42,440 number is one. 13 00:00:42,710 --> 00:00:46,910 OK, if the column title is B, then no column number is two. 14 00:00:47,360 --> 00:00:51,340 If the column title is Z, then the column number is 26. 15 00:00:52,160 --> 00:00:55,000 OK, so let's see this this one example. 16 00:00:55,010 --> 00:01:00,170 So this is basically one and this is basically going to multiply one. 17 00:01:00,410 --> 00:01:03,440 And if you will add these two, I will get twenty seven. 18 00:01:03,650 --> 00:01:06,160 OK, so B is basically two. 19 00:01:07,100 --> 00:01:11,420 This is basically during the six multiply the value of A's one. 20 00:01:11,720 --> 00:01:14,840 And if you will add these two I will get 28. 21 00:01:15,320 --> 00:01:19,160 OK, so this is the value of a is one. 22 00:01:19,550 --> 00:01:30,110 So the value of this is basically 26 multiply when the value of this is basically 26, multiply 26, 23 00:01:30,110 --> 00:01:31,190 multiply one. 24 00:01:31,670 --> 00:01:35,870 And if you will add these three, then you will get seven zero three. 25 00:01:36,510 --> 00:01:41,030 OK, so the value of Y is basically twenty five. 26 00:01:41,630 --> 00:01:47,100 The value of that is basically 26 multiply and the value of that is 96. 27 00:01:47,240 --> 00:01:50,960 If you will add these two you will get seven zero one. 28 00:01:51,150 --> 00:01:54,720 OK, so this isn't a thing, this is just the implementation problem. 29 00:01:54,790 --> 00:01:57,020 OK, it is only implementation problem. 30 00:01:57,380 --> 00:01:58,300 So what we have to do. 31 00:01:58,310 --> 00:01:59,210 So what we will do. 32 00:01:59,240 --> 00:02:02,830 Suppose I have a string, let's say ABC. 33 00:02:03,350 --> 00:02:06,390 So this is basically the column title what I will do. 34 00:02:07,040 --> 00:02:10,449 So take the value of the which is one, two, three, four. 35 00:02:10,460 --> 00:02:13,000 So its value will be for the value of these. 36 00:02:13,010 --> 00:02:16,100 Basically three and three will multiply it by 26. 37 00:02:16,790 --> 00:02:22,670 The value of B is basically two and we will multiply it with 36 and 226. 38 00:02:23,600 --> 00:02:29,930 Similarly, the value of is basically one and we will multiply it with 26, multiply 26, multiplied 39 00:02:29,930 --> 00:02:33,930 26, multiply one and then we will add all these folds. 40 00:02:33,950 --> 00:02:35,540 OK, so we will add. 41 00:02:37,830 --> 00:02:41,130 So basically what we have to do, so suppose this is. 42 00:02:42,220 --> 00:02:50,560 A very long string then, but we have to do so, I will start reading from the end, OK, I started 43 00:02:50,560 --> 00:02:51,370 reading from the end. 44 00:02:51,380 --> 00:02:58,540 I will take a variable power, which is initially one, and each time this power will get multiplied 45 00:02:58,540 --> 00:02:59,370 by 26. 46 00:03:00,110 --> 00:03:06,060 OK, and I will find out the value of the character and I will multiply the value of character with 47 00:03:06,100 --> 00:03:06,640 the power. 48 00:03:07,970 --> 00:03:10,130 OK, so let's read the cold. 49 00:03:12,090 --> 00:03:14,460 So basically, this question is present only. 50 00:03:14,910 --> 00:03:17,280 OK, so now let's take the call. 51 00:03:17,310 --> 00:03:21,440 So what they're going to do is so the plan is very simple. 52 00:03:21,690 --> 00:03:23,400 Let us take one example to understand. 53 00:03:23,970 --> 00:03:30,030 So suppose I have this a A and a OK, so I will start trading from the end. 54 00:03:30,840 --> 00:03:33,660 Let's take a variable answer, which is initially zero. 55 00:03:33,880 --> 00:03:39,510 OK, so the value of A is one and initially the value of power is one. 56 00:03:40,100 --> 00:03:41,850 OK, so the value of phase one. 57 00:03:41,970 --> 00:03:48,780 So what I will do, I will write sequels, current answer plus the value of the character. 58 00:03:49,050 --> 00:03:50,430 So in this case, this is one. 59 00:03:50,820 --> 00:03:53,820 OK, so one multiply power. 60 00:03:55,520 --> 00:04:03,500 So power is also seven, so cyclers zero plus one into one sort of answer becomes one. 61 00:04:03,680 --> 00:04:06,150 OK, now let us come here. 62 00:04:06,170 --> 00:04:10,740 So the value of A is basically one, but it will get multiplied by 26. 63 00:04:10,790 --> 00:04:13,010 OK, so what I will do, I will right here. 64 00:04:13,610 --> 00:04:15,920 Power equals power. 65 00:04:15,920 --> 00:04:18,769 Multiply 26 and I'll execute this line again. 66 00:04:20,200 --> 00:04:26,680 OK, so this is basically on set equals the current value of Unseld, which is one, so the value of 67 00:04:26,680 --> 00:04:30,670 A is one and the value of power is basically 26. 68 00:04:31,000 --> 00:04:36,110 OK, if you will add these two, you will get 27 now for this one. 69 00:04:36,820 --> 00:04:40,450 So the answer is basically 27 plus. 70 00:04:40,600 --> 00:04:42,250 So what will happen at this point? 71 00:04:42,460 --> 00:04:45,610 I will multiply power by 26. 72 00:04:46,120 --> 00:04:48,710 So the value of power was already 26. 73 00:04:48,730 --> 00:04:51,830 So this is the 626, basically 26 square. 74 00:04:52,060 --> 00:04:53,740 So this will be six, seven, six. 75 00:04:54,220 --> 00:04:59,020 OK, so six, seven, six multiplied the value of eight, which is one. 76 00:05:00,600 --> 00:05:09,360 And if you will add these two, so this will basically so seven, six, seven to nine and 10, so this 77 00:05:09,360 --> 00:05:11,840 will be basically seven zero three. 78 00:05:12,680 --> 00:05:14,610 OK, so let's see about. 79 00:05:17,340 --> 00:05:19,500 So seven zero three is the right answer. 80 00:05:19,590 --> 00:05:21,510 OK, so now let us right the good. 81 00:05:23,500 --> 00:05:25,720 So as discussed initially, my. 82 00:05:26,800 --> 00:05:28,390 I said, this is zero. 83 00:05:29,350 --> 00:05:30,220 And initially. 84 00:05:31,200 --> 00:05:37,820 I have a power variable, which is initially one, OK, I will start outrating from the end, so let's 85 00:05:37,830 --> 00:05:39,960 find out the size of the string. 86 00:05:40,380 --> 00:05:41,550 So as Nazis'. 87 00:05:43,950 --> 00:05:47,250 Now, after finding the sites, we have to read from the end. 88 00:05:47,430 --> 00:05:49,860 OK, so now let's hydrate. 89 00:05:52,410 --> 00:05:58,380 So the last FedExes and minus one and the first index is basically zero eight minus minus. 90 00:05:59,810 --> 00:06:02,870 So what we have to write, so say, was. 91 00:06:03,800 --> 00:06:07,770 And surplus, first of all, we have to find the value. 92 00:06:07,790 --> 00:06:16,470 So this is SFI, as if I will give me the corrected minus 64 y 64 because the ASCII value of capital. 93 00:06:17,360 --> 00:06:19,010 OK, so I am writing here. 94 00:06:20,590 --> 00:06:22,700 SFI minus 64. 95 00:06:23,820 --> 00:06:26,730 So this is basically will give me a character. 96 00:06:27,960 --> 00:06:36,150 OK, and this is 64, basically the assembly of capital is 65, OK, but here in our problem, the value 97 00:06:36,150 --> 00:06:37,230 of it is basically one. 98 00:06:37,260 --> 00:06:40,540 So what I will do, I will do 65 minus 64. 99 00:06:40,560 --> 00:06:42,120 So the value of it will become one. 100 00:06:42,180 --> 00:06:46,910 OK, so basically this is character minus integer. 101 00:06:46,920 --> 00:06:49,710 So whenever the situation is minus integer, what will happen? 102 00:06:49,740 --> 00:06:54,990 So this character will be converted to Tasca value, for example, if this character is be. 103 00:06:56,140 --> 00:07:02,290 So that's how I value what will become so it will become 66 and I am subtracting 64, so it will become 104 00:07:02,290 --> 00:07:06,610 two and obviously the value of being for our problem is basically two. 105 00:07:06,660 --> 00:07:06,970 OK. 106 00:07:09,340 --> 00:07:15,850 And now what we have to do so we have to multiply with the power and now the power will increment, 107 00:07:15,850 --> 00:07:18,610 so power equals power, multiply 26. 108 00:07:19,550 --> 00:07:24,520 OK, and finally, when the loop will end, we can return our answer. 109 00:07:25,400 --> 00:07:26,660 OK, so very simple. 110 00:07:30,420 --> 00:07:32,510 OK, so now let's send it out answer. 111 00:07:37,470 --> 00:07:42,580 OK, so what is happening here is we are getting rain error at this late hour equals power multiplied 112 00:07:42,580 --> 00:07:45,190 26 and why we are getting runtime error. 113 00:07:45,930 --> 00:07:47,190 So basically. 114 00:07:48,980 --> 00:07:54,800 So basically, we have in digital tape, so doing digitally type the maximum number, it can stories 115 00:07:54,800 --> 00:07:58,040 up to two to the power 31 OK in C++. 116 00:07:58,200 --> 00:08:01,570 So this is nearly ten to the power line. 117 00:08:01,640 --> 00:08:08,360 OK, now suppose this power number is a very big number and what we are doing, so we are multiplying 118 00:08:08,360 --> 00:08:11,680 this big number by 26, then what can happen? 119 00:08:11,960 --> 00:08:18,440 So this resulting number, it can become greater than 10 to the power nine, which is the range of the 120 00:08:18,440 --> 00:08:18,980 integer. 121 00:08:19,190 --> 00:08:20,920 So if this is the scenario, what will happen? 122 00:08:20,930 --> 00:08:28,880 So we will get runtime error because this big number cannot be stored in an integer variable and this 123 00:08:28,880 --> 00:08:31,400 power is basically in digital type. 124 00:08:31,670 --> 00:08:38,600 OK, so to solve this question, what we can do, so we have a data type Longlong, so the range of 125 00:08:38,600 --> 00:08:44,950 long under type is basically it can store numbers which are approved into the power rating. 126 00:08:45,050 --> 00:08:48,330 OK, so this is the range for long, long to the type. 127 00:08:48,830 --> 00:08:52,460 So if we will use long, long red tape for the power variable. 128 00:08:53,480 --> 00:08:58,820 We will not get intimidated, OK, because this big number can be stored in the long, long delay type, 129 00:08:58,880 --> 00:09:02,000 OK, so let's change the type of the power variable. 130 00:09:03,050 --> 00:09:08,810 So instead of using integer, what we will use, we will use long, long and hopefully they should work. 131 00:09:08,870 --> 00:09:10,400 OK, now let's admit. 132 00:09:16,770 --> 00:09:18,930 OK, so our goal is working fine. 133 00:09:19,170 --> 00:09:19,560 OK? 134 00:09:20,580 --> 00:09:25,250 So now let us discuss the time and the space complexity for our record. 135 00:09:25,450 --> 00:09:31,410 OK, so basically the space complexities are the rough when we are just creating only a few variables, 136 00:09:31,410 --> 00:09:31,800 OK? 137 00:09:32,010 --> 00:09:37,680 And the time complexity is basically all that often the Gulf and where and is basically the size of 138 00:09:37,680 --> 00:09:38,130 this string. 139 00:09:38,160 --> 00:09:41,670 OK, so we are just iterating from the end of the string. 140 00:09:42,750 --> 00:09:43,690 Towards the first. 141 00:09:43,780 --> 00:09:46,500 OK, so we are retreating from the end of the string. 142 00:09:46,540 --> 00:09:51,660 OK, so the time complexity is basically linear and the space complexity is basically big off one. 143 00:09:52,500 --> 00:09:55,710 OK, so if you have any doubt in this question, you can ask me. 144 00:09:55,710 --> 00:09:56,430 OK, thank you.