To understand why width = size * 4 - 3? let's say size = 3. If we see the max width in the middle, the total no. of the alphabet is 5(c, b, a, b, c), and so one dash is required in between these alphabets. so, the total no. of dashes is 4 in this case. so, if size = 3, the max width in the middle row is: 5 alphabets+4 dashes = (3+2) + (4) = (3 +2 ) + (5-1) = (3 + 2) + (3 + 2 -1) = (n + n-1) + (n + n - 1 - 1) {As n or size = 3} = (2n - 1) + (2n - 2) = 2n + 2n - 1 - 2 = 4n - 3 Therefore width = 4 * size - 3
you make problem so easy thankyou, but i have one question how you get logic of length stuart_score > kevin_score: stuart_score=+length-i can you explain
i learned python a few days ago but when solving these hackerrank problems it almost seems as if i never learned python also after watching ur video i understand the solution but the next day its as if i never saw ur solution i forgot the problem solving skills and everything seems so hard is it normal or am i lacking behind
O(n^2) solution is not a good idea. you can also just do : return new_sequence == sorted(new_sequence), to make it simpler, but still complexity will be O(n^2). Need a better solution
hey amir thanks a lot for the explanation. I always feel guilty of not being able to solve problems myself and search for solutions. How do I come up with an approach or rather an algorithm to solve problems?
Hey mate, thanks heaps for the lovely words and sharing the good. To be able to solve the problems by yourself, you really first need to learn to break the problem into smaller pieces, and then think of what needs to be done first, what next, etc. But this is not easy at first. Keep watching other videos and try to learn how to formulate your thinking. And like everything, keep practicing and you will master it🙂
I have a question about how to solve hacker rank or other websites (like leetcode,code chef etc.) python questions as I am a beginner and python is my first language .Should I complete the basics and then go to hacker rank or is there any other approach too ? It has only been a month since I started learning Python. Am I pushing myself too hard ?
I tried to solve one if else question that you solved in this video after learning the basics of if else and I got it wrong 😅. That's why I am here . Though I got some test cases correct.