1
00:00:01,020 --> 00:00:06,000
Hi, everyone, so this video is in the continuation of previous video, so we will discuss that in

2
00:00:06,000 --> 00:00:06,630
this question.

3
00:00:07,440 --> 00:00:13,680
You are given that you want to reach to the top that is in step and it is given that either you can

4
00:00:13,680 --> 00:00:16,260
take a jump of one or you can take a jump of two.

5
00:00:16,590 --> 00:00:21,090
But we have modified the question and the question is now you can take Jump-Off.

6
00:00:21,870 --> 00:00:28,110
So in this question, the value of cage basically to so the value of K can be anything, for example,

7
00:00:28,120 --> 00:00:29,850
then so the value of Gaist.

8
00:00:29,850 --> 00:00:33,740
And that means you can take a jump of one, you can take a jump of two, three.

9
00:00:33,750 --> 00:00:35,280
And so until then.

10
00:00:36,030 --> 00:00:36,470
Right.

11
00:00:36,660 --> 00:00:42,540
So let's see how we can modify this code to work for a General K, let's start writing the code, then

12
00:00:42,540 --> 00:00:43,740
you will be able to understand.

13
00:00:50,070 --> 00:00:53,730
So let's comment about this called.

14
00:01:01,900 --> 00:01:10,240
So it is pretty obvious we need to create a debris size and plus one fine next step here to initialize

15
00:01:10,240 --> 00:01:10,970
the base case.

16
00:01:11,110 --> 00:01:14,380
So let's say we are initializing DEPI of zero to one.

17
00:01:14,950 --> 00:01:18,650
If the value of any zero, how many number of B is out there?

18
00:01:18,690 --> 00:01:19,440
There is only one.

19
00:01:19,450 --> 00:01:20,530
We do not do anything.

20
00:01:21,160 --> 00:01:24,120
Now, let's talk about this.

21
00:01:25,630 --> 00:01:29,720
So one thing is pretty simple here, pretty straightforward here.

22
00:01:30,250 --> 00:01:33,510
So here's the value of keyboards, too.

23
00:01:34,420 --> 00:01:36,250
So that's why you write it two times.

24
00:01:36,250 --> 00:01:43,540
If the value of K3, what you will do, you will add Deepthi minus three if the value of KS for you

25
00:01:43,540 --> 00:01:47,240
will add plus DPF of a minus four.

26
00:01:47,440 --> 00:01:56,660
Similarly, if the value of KS 10, then you will add DEPI of a minus five ie minus six, minus 10.

27
00:01:57,370 --> 00:01:59,630
So what we need, we need a for loop here.

28
00:01:59,650 --> 00:02:00,050
Right.

29
00:02:00,760 --> 00:02:04,900
We need one for loop here to iterate or work.

30
00:02:05,530 --> 00:02:05,950
Right.

31
00:02:06,070 --> 00:02:08,130
And we are going to add all these values.

32
00:02:08,410 --> 00:02:13,300
So after adding all these values DPF, I will be an addition of all these values.

33
00:02:13,330 --> 00:02:13,810
So.

34
00:02:14,290 --> 00:02:14,740
Right.

35
00:02:15,190 --> 00:02:16,300
Pretty straightforward.

36
00:02:16,300 --> 00:02:17,300
We need a for loop.

37
00:02:18,280 --> 00:02:26,770
So first let I try to the debris so in equals one I elastin or close to when I placeless.

38
00:02:28,840 --> 00:02:37,000
Our answer will be DEPI often as we have discussed this now we need a up rate and envelope.

39
00:02:37,000 --> 00:02:38,650
We will add all the values.

40
00:02:38,650 --> 00:02:42,620
So for adding the value let's say in answer.

41
00:02:43,000 --> 00:02:48,000
So initially my answer is zero and we need a for loop to try to work.

42
00:02:49,690 --> 00:02:51,060
So okay.

43
00:02:51,280 --> 00:02:53,020
Let's name James Hardie.

44
00:02:53,210 --> 00:03:08,560
Its J equals one J list and or close to K and the J plus plus answer plus equals to deep off i.e. minus

45
00:03:08,560 --> 00:03:08,810
G.

46
00:03:10,630 --> 00:03:16,390
And when you come out of this for loop your the payoff i.e. will be this answer.

47
00:03:17,470 --> 00:03:19,890
So let me try to explain you what is happening here.

48
00:03:22,240 --> 00:03:24,670
See if the value of K is two.

49
00:03:24,790 --> 00:03:31,100
If the value of KS two then you can write i.e. minus one plus or minus two, DPL five, minus two.

50
00:03:31,390 --> 00:03:35,800
Now if the value of KS basically let's say 100, then what can do.

51
00:03:36,100 --> 00:03:45,150
You can write like this plus B of A minus three and so on until B of i.e. minus hundred.

52
00:03:45,790 --> 00:03:46,210
Right.

53
00:03:46,210 --> 00:03:47,030
You will do this.

54
00:03:47,380 --> 00:03:48,610
So basically what is this.

55
00:03:48,640 --> 00:03:49,780
This is simple for loop.

56
00:03:49,780 --> 00:03:50,090
Right.

57
00:03:50,680 --> 00:03:53,880
This is simple for loop to iterate over.

58
00:03:54,070 --> 00:03:56,400
Okay, so I am migrating here.

59
00:03:56,920 --> 00:04:02,190
So starting from one, starting from one talkee.

60
00:04:02,560 --> 00:04:08,200
Wait till I am migrating and we are what we are doing, we are adding all these values.

61
00:04:08,410 --> 00:04:09,820
So I am adding all these values.

62
00:04:09,820 --> 00:04:15,910
I started from zero, I am adding all these values and then I am assigning all these values to Deepthi.

63
00:04:16,240 --> 00:04:20,399
So I am assigning answer to the POV I write.

64
00:04:21,160 --> 00:04:25,870
So we are doing exactly the same thing now in this case, in this problem statement, the value of K

65
00:04:25,870 --> 00:04:26,650
is two.

66
00:04:26,980 --> 00:04:28,780
So let's write to.

67
00:04:32,720 --> 00:04:35,660
So it is given that the value of KS to.

68
00:04:36,780 --> 00:04:46,190
So urgent care is to right now there is one problem in the school and what is the problem?

69
00:04:46,200 --> 00:04:51,660
Problem is our court will encounter runtime error and wider and time error will happen.

70
00:04:51,990 --> 00:04:54,480
So what I am doing, I am doing I my energy.

71
00:04:54,960 --> 00:04:55,380
Right.

72
00:04:55,530 --> 00:04:58,350
What if I my energy is less than zero?

73
00:04:59,580 --> 00:05:05,490
Right, I mean, this can be less than zero, for example, if the value of AI is one and let's say

74
00:05:05,490 --> 00:05:11,260
the value of just basically so one minus K in our case, it is two to one minus two.

75
00:05:11,370 --> 00:05:12,590
It will become negative.

76
00:05:12,780 --> 00:05:14,160
It will become less than zero.

77
00:05:14,430 --> 00:05:17,520
So this value will become deep of negative something.

78
00:05:17,910 --> 00:05:18,270
Right.

79
00:05:18,270 --> 00:05:20,100
And that is basically not defined.

80
00:05:20,100 --> 00:05:21,350
That is runtime error.

81
00:05:21,750 --> 00:05:30,050
So we will only call this when I minus G is not zero, it is guerdon or close to zero G.

82
00:05:30,060 --> 00:05:31,650
What is just basically jump.

83
00:05:32,880 --> 00:05:37,620
Right, you can take a jump off when you can take a jump of two and the maximum, you can take a jump

84
00:05:37,620 --> 00:05:37,800
off.

85
00:05:38,520 --> 00:05:41,220
So let me also rename the Stooging.

86
00:05:42,960 --> 00:05:44,760
So here, Jamie's jump.

87
00:05:47,960 --> 00:05:53,540
Starting from jump one that makes them jump, that I can take is basically less than ago.

88
00:05:53,600 --> 00:05:55,990
Stookey And the value of getting this question is two.

89
00:05:56,780 --> 00:05:58,620
So this will be jump.

90
00:06:00,050 --> 00:06:09,950
And as I explained, you will only you will only call this when I Minhas jump is positive.

91
00:06:10,020 --> 00:06:11,630
That is greater than or equal to zero.

92
00:06:11,960 --> 00:06:13,850
Then only you will be able to do this.

93
00:06:14,600 --> 00:06:17,150
Otherwise your gold will give you a ring.

94
00:06:17,150 --> 00:06:19,810
Temeraire right.

95
00:06:20,600 --> 00:06:22,770
So I think I will call Wilberg.

96
00:06:22,820 --> 00:06:23,330
Let's see.

97
00:06:30,020 --> 00:06:31,380
OK, so identify.

98
00:06:31,790 --> 00:06:34,040
OK, I need to right here jump.

99
00:06:42,130 --> 00:06:43,190
Let's legitimate.

100
00:06:47,720 --> 00:06:51,820
So our goal is working now, we have a general called, right?

101
00:06:51,860 --> 00:06:53,900
So this will work for any Liedtke.

102
00:06:54,680 --> 00:06:56,840
So now what we need to do.

103
00:06:56,840 --> 00:07:00,290
So we forgot to discuss time, complexity for this problem.

104
00:07:00,320 --> 00:07:02,630
So what was the time and the space complexity?

105
00:07:03,110 --> 00:07:05,580
So we are creating a disparity of size and less.

106
00:07:06,200 --> 00:07:08,120
So this is extremely big often.

107
00:07:08,510 --> 00:07:09,590
And what is the time?

108
00:07:09,600 --> 00:07:11,830
So we are just iterating over this area.

109
00:07:11,840 --> 00:07:18,780
So time complexity is big off and in this case, what will be the time and the space complexity?

110
00:07:19,160 --> 00:07:21,660
So space complexity, you are creating this area.

111
00:07:22,010 --> 00:07:28,340
So again, the space complexity is big often because you are creating one day of sizing and what is

112
00:07:28,340 --> 00:07:29,350
the time complexity.

113
00:07:29,360 --> 00:07:37,440
So you are iterating and times and then each time you are creating daytimes.

114
00:07:37,460 --> 00:07:38,990
So and in Tukey.

115
00:07:39,770 --> 00:07:42,340
Right in this case, the value of case two.

116
00:07:42,500 --> 00:07:46,640
So this will become and in total, which is nothing but big often.

117
00:07:48,950 --> 00:07:49,340
Right.

118
00:07:49,550 --> 00:07:52,250
But this is the general time and space complexity.

119
00:07:56,070 --> 00:08:02,920
So this court will basically work for any given value of late, so we have generalized our.

120
00:08:05,100 --> 00:08:06,480
So that is pretty much that.

121
00:08:06,480 --> 00:08:08,360
I want to discuss this with video, guys.

122
00:08:08,730 --> 00:08:11,970
So if you have any doubt, please do ask.

123
00:08:11,970 --> 00:08:12,930
I will help you out.

124
00:08:13,320 --> 00:08:14,750
So this is from this video.

125
00:08:14,790 --> 00:08:16,110
I will see you in the next one.

126
00:08:16,140 --> 00:08:16,680
Thank you.

