1
00:00:00,630 --> 00:00:01,600
Hello, everyone.

2
00:00:01,620 --> 00:00:06,689
So in this video, we are going to solve one more interesting question, and the name of the problem

3
00:00:06,689 --> 00:00:07,820
is hotel reviews.

4
00:00:08,280 --> 00:00:13,350
So let's quickly go to the description of the question and let's try to find out what is the question

5
00:00:13,350 --> 00:00:14,840
and how we can solve this question.

6
00:00:16,170 --> 00:00:18,630
So let me explain the question.

7
00:00:21,670 --> 00:00:23,470
So we are given two things.

8
00:00:25,260 --> 00:00:33,510
So we are provided with two things, first is basically a string, first is basically a string, which

9
00:00:33,510 --> 00:00:38,020
is containing a list of good words separated by this underscore character.

10
00:00:38,430 --> 00:00:40,140
So how many good words are present?

11
00:00:40,470 --> 00:00:42,620
Three good words, cool ice and verify.

12
00:00:42,990 --> 00:00:48,750
So first of all, what we do, we will split this into a vector of string.

13
00:00:53,590 --> 00:00:55,900
And this are trusting what it contains.

14
00:00:55,930 --> 00:00:58,180
So it contains three words.

15
00:00:58,210 --> 00:00:59,380
First of all, is cool.

16
00:00:59,890 --> 00:01:05,080
Second word is basically ice and the third word is basically verify.

17
00:01:07,810 --> 00:01:08,230
Fine.

18
00:01:08,810 --> 00:01:10,610
Now, this second input.

19
00:01:10,870 --> 00:01:14,570
So this is Victor B and it is containing hotel reviews.

20
00:01:16,030 --> 00:01:17,000
So what is this?

21
00:01:17,020 --> 00:01:18,430
This is review.

22
00:01:20,290 --> 00:01:22,940
Number zero, because indexing starts from zero.

23
00:01:23,230 --> 00:01:28,540
So this is review number one, review one, and this is basically review to.

24
00:01:29,680 --> 00:01:30,070
Right.

25
00:01:31,170 --> 00:01:36,570
So, again, just like this, we are also going to split reviews zero in two, three words.

26
00:01:36,580 --> 00:01:40,010
So there are three words present here for Australia's water.

27
00:01:40,660 --> 00:01:46,630
Second word is basically is and third word in this review is basically coal.

28
00:01:47,710 --> 00:01:49,650
Similarly, we will do the same for this.

29
00:01:50,950 --> 00:01:55,330
The first word is basically called the second word is basically I's.

30
00:01:55,330 --> 00:01:57,340
And the third word is basically drink.

31
00:02:01,500 --> 00:02:08,880
Now, what is the problem statement, so problem statements is that you are provided with what is a

32
00:02:08,880 --> 00:02:16,350
good word and you are provided with the reviews you need to return a vector of integers which contain

33
00:02:16,350 --> 00:02:18,100
the original indexes of the review.

34
00:02:18,120 --> 00:02:19,530
So what is the original index?

35
00:02:19,710 --> 00:02:21,140
So this is index zero.

36
00:02:21,420 --> 00:02:26,530
This is index one and this is index two in this sorted order of reviews.

37
00:02:26,550 --> 00:02:28,770
So what do you mean by sort of reviews?

38
00:02:29,130 --> 00:02:33,840
So see, for this review, I'm talking about reviews zero.

39
00:02:34,140 --> 00:02:35,490
How many good words are there?

40
00:02:36,810 --> 00:02:37,970
How many good words are there?

41
00:02:37,980 --> 00:02:40,290
So how we can check that?

42
00:02:40,860 --> 00:02:43,050
So is water a good word?

43
00:02:43,830 --> 00:02:49,080
We can see here water is not present in this list of good words of water is not a good word.

44
00:02:49,500 --> 00:02:51,960
Is is not present in this.

45
00:02:52,230 --> 00:02:53,970
So is is not a good word.

46
00:02:54,450 --> 00:02:54,900
Cool.

47
00:02:54,970 --> 00:02:55,280
Yes.

48
00:02:55,280 --> 00:02:56,340
School is a present.

49
00:02:56,500 --> 00:02:58,290
So this review review No.

50
00:02:58,290 --> 00:03:00,570
Zero is containing one good word.

51
00:03:01,680 --> 00:03:05,480
And that good word is basically actually we can see cool is a good word.

52
00:03:06,120 --> 00:03:08,640
Similarly, let's talk about review number one.

53
00:03:08,640 --> 00:03:09,930
How many good words are there.

54
00:03:10,200 --> 00:03:16,260
So I think there is only one good word here and that good word is basically ice cold and drink.

55
00:03:16,260 --> 00:03:17,070
They are not good word.

56
00:03:17,070 --> 00:03:18,240
Ice is a good word.

57
00:03:18,900 --> 00:03:20,280
So one good word here.

58
00:03:21,240 --> 00:03:22,950
We can see ice is present here.

59
00:03:22,980 --> 00:03:25,170
So this is a good word for review.

60
00:03:25,170 --> 00:03:28,110
Number two, let's talk about review number two.

61
00:03:28,110 --> 00:03:29,220
How many good words are there?

62
00:03:29,430 --> 00:03:31,170
So I think there are two good words.

63
00:03:32,460 --> 00:03:33,660
Coal is a good word.

64
00:03:34,080 --> 00:03:35,250
Wipha is a good word.

65
00:03:35,250 --> 00:03:36,810
So coal is a good word.

66
00:03:36,810 --> 00:03:38,100
Vafa is a good word.

67
00:03:38,520 --> 00:03:43,500
So we can see review number zero is containing one good word.

68
00:03:44,860 --> 00:03:52,640
Review no one is containing again, one good word and review number two is containing two good words.

69
00:03:54,350 --> 00:03:54,810
Right.

70
00:03:55,070 --> 00:04:02,210
So what should be our output, so we need to report our output as the indexes, first of all, the index

71
00:04:02,210 --> 00:04:03,480
having the maximum good word.

72
00:04:03,770 --> 00:04:10,280
So this index, too, is having maximum good words, which are to index number two will come first.

73
00:04:10,760 --> 00:04:15,860
Then these two reviews are containing equal number of good words, one and one.

74
00:04:16,100 --> 00:04:17,029
So it doesn't matter.

75
00:04:17,060 --> 00:04:21,350
You can put zero and one or you can also put to one and zero.

76
00:04:21,829 --> 00:04:22,240
Right.

77
00:04:22,580 --> 00:04:26,100
So you can put 011 because review zero is containing one good word.

78
00:04:26,510 --> 00:04:32,300
Similarly, review one is containing one good word so you can print their output like this or you can

79
00:04:32,300 --> 00:04:33,830
print your output like this.

80
00:04:34,190 --> 00:04:42,080
But it is given that since zero and one they have equal number of good words, they have equal number

81
00:04:42,080 --> 00:04:42,610
of good words.

82
00:04:42,620 --> 00:04:45,620
So your answer should be this and not this.

83
00:04:47,030 --> 00:04:47,420
Right.

84
00:04:48,140 --> 00:04:50,140
Zero is coming before one.

85
00:04:50,150 --> 00:04:56,500
So that's why in the output only zero is coming before one and we can say zero is smaller than one.

86
00:04:56,510 --> 00:04:59,570
So we need to preserve the original order of the indexes.

87
00:04:59,930 --> 00:05:02,840
So this should be our output and not this.

88
00:05:04,400 --> 00:05:12,350
OK, so we need to retain our output like this to and is the output we can see in the kitchen also it

89
00:05:12,350 --> 00:05:15,230
is given that the output for discussion is basically.

90
00:05:16,660 --> 00:05:25,480
Who 091 right, so that's how you will be able to solve this question and this is a very simple question,

91
00:05:27,190 --> 00:05:28,660
but the problem is.

92
00:05:30,240 --> 00:05:31,180
The searching part.

93
00:05:33,060 --> 00:05:35,370
So how are you are going to search?

94
00:05:36,290 --> 00:05:39,920
Like, if you want to search whether water is a good word or not, what you need to do, you need to

95
00:05:39,920 --> 00:05:41,520
hydrate or this vector.

96
00:05:41,660 --> 00:05:48,890
So remember, we have created a vector of three words called ice and verify.

97
00:05:51,390 --> 00:05:56,880
For each of these words, for each of these words, what we need to do, you need to irate over this

98
00:05:57,540 --> 00:06:01,280
at Idato this vector, and then you will perform the searching.

99
00:06:01,740 --> 00:06:03,620
And this is the problem, right?

100
00:06:03,630 --> 00:06:06,660
You are going to take a lot of a lot of time for searching.

101
00:06:07,380 --> 00:06:08,510
And what is the solution?

102
00:06:08,520 --> 00:06:09,970
Solution is to use a try.

103
00:06:10,410 --> 00:06:15,540
We have discussed in our previous lessons try its best for searching.

104
00:06:15,780 --> 00:06:21,350
And then this problem in this question, the main problem is searching time will be a lot more.

105
00:06:21,660 --> 00:06:25,110
So we need to optimize our searching and for optimizing the searching.

106
00:06:25,410 --> 00:06:26,100
What do we do?

107
00:06:26,100 --> 00:06:27,220
We will use try.

108
00:06:27,840 --> 00:06:30,920
So what we do, we will make a try of all the good words.

109
00:06:31,410 --> 00:06:34,270
So we are going to make a try of all the good words.

110
00:06:34,290 --> 00:06:36,630
So the first good word is cool ice and verify.

111
00:06:36,960 --> 00:06:39,960
So cool I.

112
00:06:41,520 --> 00:06:42,370
And by far.

113
00:06:43,230 --> 00:06:52,110
So we will make a try of all these words, all good words, we are going to insert all the good words

114
00:06:52,110 --> 00:06:55,530
in a try so that we can optimize our searching part.

115
00:06:58,590 --> 00:07:06,960
And how you can build this dry, so what you need is you need to define the north structure, which

116
00:07:06,960 --> 00:07:11,490
you have defined in our last review, and you need to write the code for the area function will basically

117
00:07:11,620 --> 00:07:14,100
actually add Ice Adibi to the.

118
00:07:14,790 --> 00:07:20,220
So how the add function works that we have discussed in our previous lesson and for all these words,

119
00:07:20,220 --> 00:07:22,680
what need to do, you need to call the function such.

120
00:07:24,490 --> 00:07:30,160
And the code for research we have written in our last review, we will search whether water is present

121
00:07:30,160 --> 00:07:34,390
in this trial or not, Google is present in this trial, not ISIS.

122
00:07:34,390 --> 00:07:38,250
Present and destroy or not verify is present in this trial or not.

123
00:07:38,530 --> 00:07:42,790
So the main problem, the problem here was the searching problem.

124
00:07:43,240 --> 00:07:49,450
Therefore, each word you need to arbitrate over this area to figure out how many good words are present.

125
00:07:49,630 --> 00:07:51,300
But now, since we have a trial.

126
00:07:51,310 --> 00:07:53,350
So I was searching parties optimized.

127
00:07:54,580 --> 00:07:59,560
So that's what, guys, in this problem, the main logic, the main logic behind this problem is to

128
00:07:59,740 --> 00:08:06,530
use try OK and for try, you need to write the code for our function and search function, which we

129
00:08:06,580 --> 00:08:09,000
have discussed in our previous lessons rest.

130
00:08:09,100 --> 00:08:10,570
The problem is very, very simple.

131
00:08:10,870 --> 00:08:16,090
Just insert all the code words in a tray and for each word here, just call the search function and

132
00:08:16,090 --> 00:08:16,930
maintain the count.

133
00:08:16,930 --> 00:08:22,900
And then basically the remaining parties basically start the output according to the question demands.

134
00:08:23,530 --> 00:08:24,040
Simple.

135
00:08:24,370 --> 00:08:29,050
So this is a very simple problem and you can write the code for this problem yourself.

136
00:08:29,410 --> 00:08:31,540
So, guys, this is it from this video.

137
00:08:31,540 --> 00:08:35,159
I will see you with many more good questions in our next videos.

138
00:08:35,409 --> 00:08:36,220
So this is it.

139
00:08:36,220 --> 00:08:37,520
I will see you in the next one.

140
00:08:37,539 --> 00:08:38,080
Thank you.

