Solve any Pattern Question - Trick Explained | 22 Patterns in 1 Shot | Strivers A2Z DSA Course

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ม.ค. 2025

ความคิดเห็น • 1.5K

  • @takeUforward
    @takeUforward  2 ปีที่แล้ว +466

    Let's march ahead, and create an unmatchable DSA course! ❤
    Do consider to give us a like, and a subscribe, means a world to us..

    • @giit85
      @giit85 2 ปีที่แล้ว +2

      ❤️

    • @bhanupratapsharma6158
      @bhanupratapsharma6158 2 ปีที่แล้ว +4

      competitive programming content plz sir how to reach candidate master i was stucked on specialist

    • @tuhindas9777
      @tuhindas9777 2 ปีที่แล้ว +1

      Thank you dada love from Kolkata

    • @23cash86
      @23cash86 2 ปีที่แล้ว +1

      STL next?

    • @techyouknow8026
      @techyouknow8026 2 ปีที่แล้ว +3

      Happy new Year , Please Sir upload all the basics lecture within 2 months as I trust you so I can request you please upload frequency maintain , I like all your video after watching it completely, also you are helping others to achieve their new year resolution.

  • @muhsin.k
    @muhsin.k 2 ปีที่แล้ว +250

    Intro: 0:00
    BuildUp Logical Thinking w/ patterns: 0:20
    Pattern_01: 1:34
    4 Rules for solving patterns: 2:24
    Pattern_02: 14:17
    Pattern_03: 17:33
    Pattern_04: 19:53
    Pattern_05: 21:00
    Pattern_06: 23:39
    Pattern_07: 24:33
    Pattern_08: 31:10
    Pattern_09: 34:16
    Pattern_10: 35:12
    Pattern_11: 39:22
    Pattern_12: 42:15
    Pattern_13: 46:52
    Pattern_14: 48:42
    Pattern_15: 50:57
    Pattern_16: 53:03
    Pattern_17: 54:42
    Pattern_18: 59:45
    Pattern_19: 1:01:28
    Pattern_20: 1:06:36
    Pattern_21: 1:12:29
    Pattern_22: 1:15:41
    Like!!: 1:21:17

  • @sumitapathak2900
    @sumitapathak2900 ปีที่แล้ว +238

    I was losing confidence in my DSA skills after being away for so long. This video sharpened my thinking as well as brought back that confidence. Thanks a lot !!

    • @FRACTALUMAR
      @FRACTALUMAR 6 หลายเดือนก่อน

      did you solve them by your own or first watched ,then, practice them ....

    • @vahramirpunit
      @vahramirpunit 3 หลายเดือนก่อน +1

      @@FRACTALUMAR i first watched whole video once, then i solved most of the problems on my own, if needed i came back to video.

    • @pradumyelame6462
      @pradumyelame6462 17 วันที่ผ่านมา

      am also solving the 300+ problem but not prety sure to gaining the confidence in problem solving but after watching this video am same as much confidence and understabding the loop and there flow so one doubt is clear if your not able to solve any problem because of the logic building then solve this pattern and back to the problem solving

  • @sachinboreoffl
    @sachinboreoffl 2 ปีที่แล้ว +792

    Tip:
    When you're printing spaces in a pattern, replace the space with any other symbol like this "-", it helps in understanding what we are doing.

    • @RahulChacko
      @RahulChacko ปีที่แล้ว +5

    • @jaydeeppatil7936
      @jaydeeppatil7936 ปีที่แล้ว +5

      Thanks a lot it really helped me

    • @anusha6033
      @anusha6033 ปีที่แล้ว +2

      nice one thanks for sharing

    • @suryasaipalthi
      @suryasaipalthi ปีที่แล้ว

      thanks for sharing that did change my way of thinking somewhat

    • @harshyadav1214
      @harshyadav1214 ปีที่แล้ว

      very good approach

  • @md.ualiurrahmanrahat2400
    @md.ualiurrahmanrahat2400 ปีที่แล้ว +43

    saw a lot of videos before to understand pattern 22. But never got it. The way you solved it!!! What can I say. We owe you big time brother.

  • @rajeshvarma2162
    @rajeshvarma2162 8 หลายเดือนก่อน +97

    In Pattern18, we should not hardcode the value 'E', It should be dynamic.
    void pattern_18(int n) {
    for (int i=0; i

    • @Hades0210
      @Hades0210 7 หลายเดือนก่อน +4

      Exactly

    • @ictfan-ly8gh
      @ictfan-ly8gh 5 หลายเดือนก่อน +2

      Yes bro u are 👍

    • @ictfan-ly8gh
      @ictfan-ly8gh 5 หลายเดือนก่อน +2

      He could have use
      Char ch= 64+n

    • @kartikgtm7
      @kartikgtm7 4 หลายเดือนก่อน +6

      its wrong bro...The correct solution is....
      for(int i=0;i

    • @ImaamJIJ
      @ImaamJIJ 4 หลายเดือนก่อน +1

      we can use this for coding ninjas practice
      for (int i = 1; i ='A'+(n-i); ch--) {
      System.out.print(ch+" ");
      }
      System.out.println();
      }

  • @chiragPatel22c
    @chiragPatel22c 2 ปีที่แล้ว +63

    last pattern is mind blowing!!! hard to get that logic at first sight.

  • @raavanan00792
    @raavanan00792 8 หลายเดือนก่อน +10

    Thanks for the great content ❤
    @tip for the pattern 18 the logic in the video is hardcoded for 'E' letter alone . Kindly utilize the below solution.
    void alphaTriangle(int n) {
    for(int i=0;i

    • @HarshDPatil123
      @HarshDPatil123 2 หลายเดือนก่อน

      i think your code does opposite .
      E
      E D
      E D C
      E D C B
      E D C B A

    • @HarshDPatil123
      @HarshDPatil123 2 หลายเดือนก่อน

      maybe letter = 'A + n-i-1

  • @nisha1841
    @nisha1841 2 ปีที่แล้ว +320

    Bhaiya learning DSA from your AtoZ sheet . i am in final year I can't thank you enough for bring light in my dark future..when everyone is saying that "tumse an ho payega "I finally decided that "ab mujhse hi ho payega" thank you bhaiya .and please agle 3 month take intermediate level ka DSA sikha do.

    • @AryanKumar-qj9ud
      @AryanKumar-qj9ud 2 ปีที่แล้ว +10

      Same stry wish the best

    • @uniquescience7047
      @uniquescience7047 ปีที่แล้ว +6

      All the best to you😁

    • @known878
      @known878 ปีที่แล้ว +12

      Bhai tumne bola ki 3 month takk intermediate DSA sikha do aur tumhare comment ke bhi 3 months ho gaye to sikh liye kya intermediate wala?

    • @nisha1841
      @nisha1841 ปีที่แล้ว +9

      @@known878 ha bhai intermediate level ka almost complete hai . Strive ki AtoZ sheet se padha hai maine usme se question bnao shi rhega

    • @prajjwal5520
      @prajjwal5520 ปีที่แล้ว +2

      placement lg gyi?

  • @Cvx_ishere
    @Cvx_ishere ปีที่แล้ว +9

    Literally, breaking whole concepts into 3 steps really really help me as beginner to understand patterns. Thankyou striver b :)

  • @nehathakur40
    @nehathakur40 2 ปีที่แล้ว +64

    you are an inspiration for programming faternity! loved the way you teach. The ease with which you have taught recursion and dp is commendable. i get to learn every day from you. Thank you for being light in lives of programmers.

    • @raunak276
      @raunak276 2 ปีที่แล้ว +1

      fr

    • @sainaid
      @sainaid ปีที่แล้ว

      no doubt striver bhaiya has made this playlist the best way.

  • @prathameshdhanajigandule4299
    @prathameshdhanajigandule4299 9 หลายเดือนก่อน +9

    The better and correct code for pattern no.18 1:01:00 would be :
    void pattern18(int n){
    for(int i = 0 ; i < n ; i++){
    for(int j = i ; j >= 0 ; j--)
    cout

    • @keisergg8701
      @keisergg8701 8 หลายเดือนก่อน +8

      yep! I did same as you, here is my java code if anyone cares
      public static void pattern18(int n) {
      for (int i = 0; i < n; i++) {
      char ch = 'A';
      char chs = (char)(ch + (n-i-1));
      for(int j=0; j

    • @prathameshdhanajigandule4299
      @prathameshdhanajigandule4299 8 หลายเดือนก่อน +2

      @@keisergg8701 Yes bro it's correct I care

    • @vikasverma5685
      @vikasverma5685 6 หลายเดือนก่อน +1

      ​​@@keisergg8701
      public static void pattern18(int n){
      for(int i = 0; i < n; i++){
      for(char ch = (char)('E'- i); ch

    • @abishek.s4724
      @abishek.s4724 11 วันที่ผ่านมา

      @@vikasverma5685
      public static void alphaTriangle(int n) {
      for(int i=1;i

    • @AshishKhetwal
      @AshishKhetwal 43 นาทีที่ผ่านมา

      @@keisergg8701 I care and thanks a lot appreciate you

  • @eleveneleven4195
    @eleveneleven4195 2 ปีที่แล้ว +50

    for code 14 we can also try :🙂
    for(int i=1;i

    • @dllychoudhary7586
      @dllychoudhary7586 9 หลายเดือนก่อน +3

      I literally did the same... because there was error that character can not add with int..so i did with your method

    • @honourable8816
      @honourable8816 8 หลายเดือนก่อน

      ​@@dllychoudhary7586 You can use
      cout

    • @TiyaBhatt4-de8sq
      @TiyaBhatt4-de8sq 8 หลายเดือนก่อน

      @@dllychoudhary7586 I am facing the same error in question 16 . What should I do?

    • @yashiktaneja673
      @yashiktaneja673 7 หลายเดือนก่อน

      ​@@TiyaBhatt4-de8sq
      char ch='A';
      for(int i=1; i

    • @vikas303k
      @vikas303k 20 วันที่ผ่านมา

      @@TiyaBhatt4-de8sq use type conversion

  • @PrabhjotSingh-o4s
    @PrabhjotSingh-o4s 6 หลายเดือนก่อน

    If You Start From Loop from 0 the formula will be lil bit easier helps more to understand for a beginner
    23:18
    For Printing
    *****
    ****
    ***
    **
    *
    for(int i=0;i

  • @SurabBarve
    @SurabBarve 2 หลายเดือนก่อน +3

    for 7th pattern if you use the formula j

  • @nexxerjm348
    @nexxerjm348 ปีที่แล้ว

    Patter seventeen :@58:53
    Solution is very
    Here is approach
    first print space then print ascending order charcater till i
    Then print descending order till i-1
    First loop for space: j=1 to j

    • @SathwikPentapati-vc4dn
      @SathwikPentapati-vc4dn 9 วันที่ผ่านมา

      this is not efficient way because the time complexity is n^3

  • @samuelfernandes3301
    @samuelfernandes3301 ปีที่แล้ว +10

    striver i think you made a little mistake in pattern18 your considering j as E, but the start letter depends on number of rows, therefore the code will work for more test cases
    void pattern18(int n){
    for (int i = 1; i

  • @Seraexplores
    @Seraexplores 7 หลายเดือนก่อน +1

    Pattern 19 simpler:
    def pattern19(n):
    for i in range(1, 2*n + 1):
    stars = n-i+1
    if i > n:
    stars = i-n
    spaces = 2*n - 2*stars

    for j in range(stars):
    print("*", end="")
    for k in range(spaces):
    print(" ", end="")
    for j in range(stars):
    print("*", end="")
    print()

  • @debashmansarbadhikari6196
    @debashmansarbadhikari6196 ปีที่แล้ว +20

    For pattern number 12 we could also have done the following :
    int space = 2 * ( n - i )...ofcourse this variable would have to be defined within the scope of the outer loop.
    Besides, the problem given on the sheet and the problem redirected to by the link are actually slightly different.
    Here's the code snippet for solving the problem redirected to by the link :
    void printTriangle(int n)
    {
    for(int i = 1; i

    • @abhisheksantoshbhambe7617
      @abhisheksantoshbhambe7617 10 หลายเดือนก่อน +1

      thanks dude!! i thought y im not getting it, and u coreected me

    • @parulchaudhary19
      @parulchaudhary19 25 วันที่ผ่านมา

      Thankyou so much brother ! 💖

  • @sidharthjoshi6859
    @sidharthjoshi6859 25 วันที่ผ่านมา +1

    The better and correct code for pattern no.18 1:01:00 would be :
    void alphaTriangle(int n) {
    char a = 64+n;
    for(int i = 1; i

  • @ankushhv6972
    @ankushhv6972 ปีที่แล้ว +23

    Hey Striver, i think for the pattern 18, we should not directly start from 'E', I think according to pattern we should be starting form ('A' + n - i + 1) until ('A' + n),
    for(int i = 0; i < n; i++) {
    for(char ch = 'A' + (n - i - 1); ch < 'A' + n; ch++) {
    cout

    • @shaharslan3372
      @shaharslan3372 ปีที่แล้ว +4

      Yes, Ankush I also noticed this. Using this approach makes it dynamic for all inputs of 'n'. Good Job

    • @inf3rno464
      @inf3rno464 6 วันที่ผ่านมา

      @@shaharslan3372 WHY DYNAMIC bro ....

  • @damolaOnikoyi
    @damolaOnikoyi 7 หลายเดือนก่อน +4

    Thank you Striver, preciate ya!!. I just completed all the pattern problems. The last one was quite tricky as I did not quickly understand your solution. However, I have provided my solution below for others that might find it helpful and maybe easier to understand.
    Intuition: Fill the 2D array (named result) with the values (n, n-1, n-2 ...) then just simply print it out (row x column)👍🏾.
    You can fill the result array like this :
    1. Outer loop fills the layer (A layer is a square ring of numbers).
    2. Get the number to be filled per layer => int num = n - layer. Hence if n = 3, layer = 0 (first one) -> n , n - 1, n - 2 ... so we print 3, 2, & 1 per square ring.
    3. Middle loop iterates over the rows of the current layer.
    4. Inner loop iterates over the columns of the current layer.
    static void pattern22() {
    int size = 2 * n - 1;
    int[][] result = new int[size][size];
    for (int layer = 0; layer < n; ++layer) {
    int num = n - layer;
    for (int i = layer; i < size - layer; ++i) {
    for (int j = layer; j < size - layer; ++j) {
    result[i][j] = num;
    }
    }
    }
    for (int[] row : result) {
    for (int col : row) {
    System.out.print(col + " ");
    }
    System.out.println();
    }
    }

  • @sasmitsirroco
    @sasmitsirroco 6 หลายเดือนก่อน +7

    For pattern 7, why print spaces after astrix?
    Simply cout

    • @PumpDomains44
      @PumpDomains44 20 วันที่ผ่านมา

      Yes, you're right, you don't need to do so

  • @hasanuzzamananuz8270
    @hasanuzzamananuz8270 ปีที่แล้ว +10

    More than the premium course I have learned a lot. The lecture delivery, explanation, and expression are great, and that makes me concentrate more to watch the video. I have done all the problems on my own using your 4 pattern-solving rules. Hats off sir ❤❤❤❤❤❤❤❤❤❤

    • @zenmonk29
      @zenmonk29 6 หลายเดือนก่อน

      today i lost my phone. it was 19 days old. went to police station to file a report, the inspector had the same name as you

    • @hasanuzzamananuz8270
      @hasanuzzamananuz8270 6 หลายเดือนก่อน

      @@zenmonk29 So what, Multiple people have under the same name.

  • @tusharkumar7963
    @tusharkumar7963 ปีที่แล้ว +3

    The best video on solving patterns on TH-cam! Can't thank you enough!!!😀😀

  • @icodecrush
    @icodecrush 2 หลายเดือนก่อน

    39:39 Pattern11 Could be done using different logic.
    // Outer loop = rows/Lines
    for (int i = 0; i < n; i++) {
    // innerloop = Collumns
    for (int j = 0; j

  • @Manish-wk8ni
    @Manish-wk8ni 2 ปีที่แล้ว +7

    Thank You, we are all hooked up. This is gonna be a Great Series.

  • @soubhikghosh6564
    @soubhikghosh6564 2 ปีที่แล้ว +22

    It doesnot come interviews i agree. But still i would urge all to do this exercise... It will help all Software engineers or aspirants to improve their problem solving skills by seeing patterns

    • @priyankabhagoriya276
      @priyankabhagoriya276 2 หลายเดือนก่อน +2

      Hmare clg m placement m ye pattern hi puche the bs 3 logo se bne the bs phle ye dekh liya hota to syd mera bhi placement ho jata but ab practice kr rhi hu

    • @HarshDPatil123
      @HarshDPatil123 2 หลายเดือนก่อน +1

      @@priyankabhagoriya276 did you get placement ? off campus?

  • @abhisheksahu3453
    @abhisheksahu3453 3 หลายเดือนก่อน +1

    for pattern 15 even more simpler code :
    void printPattern(int n)
    {
    int i;
    for(i=0;i

  • @ramfattah211
    @ramfattah211 ปีที่แล้ว +8

    The last pattern took me some time but I just figured it out and i'm so happy 🧠🤯. Such a great feeling😊. Thank you Striver for this amazing content.

  • @awesome3604
    @awesome3604 9 วันที่ผ่านมา +1

    tip pattern-11
    if flipping gets too annoying you can check the sun of loop variables inner and outer depending on initial condition ie i=1or 0 you can use if else statement to print correct pattern without much thinking
    for(int i=1; i

  • @shuskane
    @shuskane ปีที่แล้ว +70

    UNDERSTOOD
    👍
    👍👍
    👍👍👍
    👍👍👍👍
    👍👍👍👍👍

    • @kshitijsingh1990
      @kshitijsingh1990 4 หลายเดือนก่อน +2

      haha smart!

    • @Apheta_a
      @Apheta_a 3 หลายเดือนก่อน +1

      let n=5
      for (let i=0;i

    • @udaykumar-jj1gw
      @udaykumar-jj1gw 3 หลายเดือนก่อน +2

      @@Apheta_a
      😂
      😂😂
      😂😂😂
      😂😂😂😂
      😂😂😂😂😂

  • @vidhveshchangalasetty
    @vidhveshchangalasetty 7 หลายเดือนก่อน

    18th pattern
    We should define a const char starting alphabet of each line by taking the char ch='A'+n-i (before starting the outer for loop)
    void alphaTriangle(int n) {
    char ch = 'A' + n - 1;
    for (int i = 0; i < n; i++) {
    for (char c = ch; c >= ch - i; c--) {
    cout

  • @spdks3485
    @spdks3485 2 ปีที่แล้ว +11

    HAPPY NEW YEAR SIR
    HAVE A GREAT YEAR AHEAD
    AND WE ARE VERY GLAD TO GET THE HELPING PERSON LIKE YOU FOR BEGINERS LIKE US.

  • @konstantinossimatos3466
    @konstantinossimatos3466 หลายเดือนก่อน

    52:45
    void printZ(int n){
    for(int i = n-1; i >= 0; i--) {
    for(char ch = 'A'; ch

  • @mehtabmultani3194
    @mehtabmultani3194 ปีที่แล้ว +15

    39:22 tip for pattern 11:
    if the sum of every single (row+column) is 'even' then have to print 1 else 0
    if((i + j) % 2 === 0) print(1) else print(0)

    • @satyam-seth
      @satyam-seth 10 หลายเดือนก่อน +3

      void printPattern(int n)
      {
      for (int i = 0; i < n; i++)
      {
      for (int j = 0; j

    • @012srishtisaini7
      @012srishtisaini7 7 หลายเดือนก่อน +1

      @@satyam-seth thankss.. i was having a bad time because of this

  • @konstantinossimatos3466
    @konstantinossimatos3466 หลายเดือนก่อน

    31:00
    void printX(int row, int col){
    for(int i = 0; i < row; i++) {
    for(int j = 0; j < col; j++) {
    if(i+j

  • @gunasekarb3100
    @gunasekarb3100 7 หลายเดือนก่อน +66

    whoever found the logic for the pattern 22 must be an alien.

    • @winter_hope_
      @winter_hope_ 7 หลายเดือนก่อน +3

      🤣

    • @LUchiha-dt6xv
      @LUchiha-dt6xv 6 หลายเดือนก่อน +1

      I did found the logic myself(different but same answer though) but the logic used here is damn crazy🥲

    • @gunasekarb3100
      @gunasekarb3100 6 หลายเดือนก่อน

      @@LUchiha-dt6xv did you use spiral way?

    • @LUchiha-dt6xv
      @LUchiha-dt6xv 6 หลายเดือนก่อน +1

      @@gunasekarb3100 Idk about that😅, but divided the whole patter into 4 parts & designed the parts & framed them one by one(basically the brute force approach u could say)

    • @abhishekpattanayak1443
      @abhishekpattanayak1443 5 หลายเดือนก่อน +1

      @@LUchiha-dt6xv you can also try using chebyshev distance for each (i,j) from the middle-most index

  • @lekhanachidananda
    @lekhanachidananda ปีที่แล้ว +33

    Thank you Striver! I really love your videos. Small suggestion: you could have calculated time and space complexity for all the patterns.

  • @sheetaljain3569
    @sheetaljain3569 2 หลายเดือนก่อน +1

    For the 11th Pattern, I thought if both column and row are of the same type(i.e. (even, even) and (odd, odd)) the sum of the row will be even, then we have to print 1 and when are different the sum is going to be odd. So, I tried it in a different way. Here's my approach:
    for(int i=0;i

  • @mahirshah763
    @mahirshah763 5 หลายเดือนก่อน +4

    In Pattern 22, if someone is coding in c language, there is no min() function so it can be written like this by creating a function:
    #include
    int minimum(int a,int b, int c, int d);
    int main()
    {
    int num=4;
    int n=2*num-1;
    for(int i=0;i

    • @nithin999jw
      @nithin999jw 2 หลายเดือนก่อน

      you can simply edit

    • @amogh708
      @amogh708 หลายเดือนก่อน

      Bruhhhhh, 😭
      int minimum(int a, int b, int c, int d)
      {
      int min = a;
      if (b

  • @ritusingh8616
    @ritusingh8616 8 หลายเดือนก่อน +1

    Thank you for this content! This video helped a lot!
    Kindly correct the code for pattern 18 to adapt to different values of input...
    void print18(int n){
    for(int i=1; i

  • @mrnonsenseju
    @mrnonsenseju 2 ปีที่แล้ว +4

    New exciting videos in new year... Thanks Striver Bhaiya.... Love from Jalpaiguri

  • @keerthanasathish3684
    @keerthanasathish3684 11 หลายเดือนก่อน

    Alternate code for pattern 5 has runtime 17ms
    void seeding(int n) {
    for(int i=0;i

  • @shaharslan3372
    @shaharslan3372 ปีที่แล้ว +6

    Edited : Saw you correct it in the next question :-D
    For pattern 19 , I don't think we should hard code the number of spaces as 8 and then keep on decreasing the number by 2 with each iteration , as it will only work for input n = 5. Rather there should be a general formula :
    for(int i = n ; i >=1; i--){
    for(int j =1; j

    • @AdityaVerma-hh1ox
      @AdityaVerma-hh1ox ปีที่แล้ว +3

      This is wrong bro

    • @SpewFactsBeTrueToYourselves
      @SpewFactsBeTrueToYourselves 4 หลายเดือนก่อน

      i did pattern 19 myself by running 6 for loops and without seeing strivers explanation based on previous patterns knowledge , it took me 2 hrs to first draw it on book and break it into smaller chunks and then write code, row number is the game changer in second half rhombus

  • @kumaraditya5513
    @kumaraditya5513 10 หลายเดือนก่อน +1

    A different yet similar approach to Pattern 11 (java)
    39:22
    int num = 1;
    for (int i=1; i

  • @sabashh8208
    @sabashh8208 2 ปีที่แล้ว +8

    For pattern18 if we don't want to hardcode 'E' and use it for other row numbers then we can make small change as
    char initial = (char) ('A'+ (n-1));
    for (int i = 0; i < n; i++) {
    for (char c = (char) (initial - i); c

    • @NikitaNair
      @NikitaNair ปีที่แล้ว +2

      I was looking for this!!!

    • @anishchhabra6085
      @anishchhabra6085 ปีที่แล้ว

      Python code for the same:
      for i in range(n):
      char = 65
      for j in range(i+1):
      print(chr((n-i-1)+char),end="")
      char += 1
      print('
      ',end="")

  • @karthikeyabollu7121
    @karthikeyabollu7121 2 ปีที่แล้ว +6

    pattern 20 is same as pattern 19 but just interchanging the spaces and stars variables. that means no.of stars in pattern 20 will be same as no.of spaces in pattern 19 and vice-versa.

  • @sphereofcalmness2488
    @sphereofcalmness2488 2 หลายเดือนก่อน

    The best video on how to code patterns. Step-2 is GOLD!

  • @anil-chaturvedi
    @anil-chaturvedi ปีที่แล้ว +3

    Thank you for this logic-building lecture. I'm feeling confident about pattern questions.

  • @frekkytanish
    @frekkytanish 4 หลายเดือนก่อน

    for pattern 16 :
    int n;
    cin>>n;

    for(char ch = 'A' ; ch < 'A'+ n ; ch++ ){
    for(int cha = 'A' ; cha

  • @tgxgaming5880
    @tgxgaming5880 10 หลายเดือนก่อน +4

    31:00 What if we don't print the last space ? Like, After the stars. Does it improve TC(Time Complexity)?

  • @shivendradwivedi8887
    @shivendradwivedi8887 7 หลายเดือนก่อน

    In pattern 20 , for stars and spaces we can do this way also
    int stars = i;
    int spaces = 2*n - 2*i;
    if(i > n){
    stars = 2*n - i;
    space = 2*i - 2*n;
    }

  • @neoteric_nk
    @neoteric_nk ปีที่แล้ว +6

    Nice explanation sir!
    Just wanna give a general code for Pattern 18.
    void pattern18(int n){
    char ch= 'A'+n-1;
    for(int i=0; i

  • @stith_pragya
    @stith_pragya ปีที่แล้ว +1

    UNDERSTOOD......Thank You So Much for this wonderful video..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @4444-c4s
    @4444-c4s ปีที่แล้ว +4

    A little catch for Pattern-7. Don't need to print last spaces. Just 2 inner for loops will work.

  • @yuuji-kun3061
    @yuuji-kun3061 7 หลายเดือนก่อน +1

    1:01:25
    In Pattern18, we should not hardcode the value 'E', It should be dynamic.
    void pattern_18(int n) {
    for (int i=0; i

    • @mx5enthusiast
      @mx5enthusiast 7 หลายเดือนก่อน

      Exactly what I was thinking.

  • @detaqwer
    @detaqwer 2 ปีที่แล้ว +21

    Hey Raj, for pattern 11 we can try this code as well which is simpler
    void print11(int n)
    {
    for (int i = 1; i

    • @chethanprabhu4475
      @chethanprabhu4475 ปีที่แล้ว +4

      Can simplify even further
      void print11(int n)
      {
      for (int i = 1; i

    • @blockyquasar
      @blockyquasar 7 หลายเดือนก่อน

      @@sagarshah5341 kaise bhai? same hi hai dono me, n square hai dono me

    • @sagarshah5341
      @sagarshah5341 7 หลายเดือนก่อน

      @@blockyquasar I do not remember why I said that!

  • @BALAJITVECstudent
    @BALAJITVECstudent 2 หลายเดือนก่อน

    for pattern 7 i have tried with two inputs and using conditional statements it works well with the input of n=5 and m=9
    The logic of the code is
    for (int i = 1; i

  • @k-gos
    @k-gos 2 ปีที่แล้ว +28

    What will be the frequency of lectures and will you teach the complete DSA in this course? Also what will be the tentative duration of this course? Great lec btw

  • @jayeshb9323
    @jayeshb9323 10 หลายเดือนก่อน +2

    Absolutely loved the video..the way you explained it made it very easy to understand complicated problems

  • @Tyler_Durden.999
    @Tyler_Durden.999 9 หลายเดือนก่อน +129

    Is anyone doing it using Java?

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 2 ปีที่แล้ว +36

    Revision done😄

    • @mr.batman2348
      @mr.batman2348 6 หลายเดือนก่อน

      hello paji koi dc ya linkedin profile wagera

  • @sanjanakumari984
    @sanjanakumari984 2 หลายเดือนก่อน

    for question no. 18, hard coded value is written
    JavaScript solution -
    function printPattern(n) {
    for (let i = 1; i < n+1; i++) {
    let row = "";

    for (let j = 1; j < i+1; j++) {
    row += String.fromCharCode(65 + (n - j)) + " ";
    }
    console.log(row.trim());
    }
    }
    printPattern(5);
    python soln -
    def alphaTriangle(n: int):
    for i in range (1, n+1):
    for j in range(1, i+1):
    print(chr(65 + (n-j)), end = ' ')
    print()
    pass

  • @rishav144
    @rishav144 2 ปีที่แล้ว +4

    one of the best videos 🔥

    • @GauravThinks
      @GauravThinks 2 ปีที่แล้ว

      bhai poori to dekh le pehle

    • @yikes3807
      @yikes3807 2 ปีที่แล้ว

      @@GauravThinks xd

  • @PriyankaKumari-cm3kq
    @PriyankaKumari-cm3kq 5 หลายเดือนก่อน +1

    Problem no. 18 code-
    void alphaTriangle(int n) {
    for(int i=0;i

  • @luckshaeey
    @luckshaeey 2 ปีที่แล้ว +9

    last pattern was awesome. I followed another method and figured out some another pattern and symmetricity in it. But your approach was very informative too.

    • @darkexodus6404
      @darkexodus6404 ปีที่แล้ว +1

      Same. From outermost square to the innermost square. I did it like this.

    • @Jaishreeram-ly2jm
      @Jaishreeram-ly2jm 4 หลายเดือนก่อน

      can u share your method?

  • @_TashfiqTaif
    @_TashfiqTaif 11 หลายเดือนก่อน +1

    IN problem 7 : No i think no need last space . I mean, space and star print the same thing .. Thank you sir
    code:
    #include
    using namespace std;
    #define ll long long
    int main()
    {
    int n;
    cin>>n;
    for(int i=1;i

  • @cinime
    @cinime 2 ปีที่แล้ว +4

    Understood! Super amazing explanation as always, thank you very much!!

  • @meghanshrao5878
    @meghanshrao5878 4 หลายเดือนก่อน

    /// Pattern 14 :(ALTERNATE)
    void print14(int n){
    for(int i=0;i

  • @rishabh_pant
    @rishabh_pant 2 ปีที่แล้ว +9

    Source code ?
    I have learned Star space star patterns with your trick ❤️‍🔥.
    It would be better if you normalize and use loop from 0 or 1 for every problem :) cheers !!!

  • @BoraSaiVenkataPraveenKumar
    @BoraSaiVenkataPraveenKumar 2 หลายเดือนก่อน

    Understood.
    A very clear explanation on understanding the patterns and clear approach on printing the patterns.

  • @KeepCoding69
    @KeepCoding69 ปีที่แล้ว +5

    Better solution for Pattern no.12 (using only 2 for loop) :
    #include
    using namespace std;
    int main()
    {
    int n = 9;
    int start = 1;
    int end = n*2;
    int temp;
    for (int row = 1; row

  • @HemasaicharanK
    @HemasaicharanK 4 หลายเดือนก่อน

    Thank you for your clear and concise explanation. I used to follow you for so long on LinkedIn, but didn't get a chance to watch your content. Now is the time for me to get prepared for a DSA interview.

  • @lavanya_m01
    @lavanya_m01 11 หลายเดือนก่อน +1

    Understood! Can't thank you enough, God bless you for your wonderful contribution to the community

  • @SoumeshRanger111
    @SoumeshRanger111 2 ปีที่แล้ว +5

    Thank you for the video, If possible could you please share the tasks.json file here, i.e. how you're writing to the output file simultaneously.😊😊

  • @preethamreddy9610
    @preethamreddy9610 2 หลายเดือนก่อน +1

    Understood. Today is November 18th, 2024, i have started my journey with Strivers SDE sheet, i will come here periodically to update my status and my offers! Wish me luck!

  • @Yash_Raj_J
    @Yash_Raj_J 2 ปีที่แล้ว +4

    If possible can you tell us another method for pattern 22? I did not understand. BTW THANKS A LOT BHAIYA

    • @BhuvaneswariSura
      @BhuvaneswariSura ปีที่แล้ว +1

      import java.util.*;
      class Pattern
      {
      public static void main(String args[])
      {
      int n=7;
      int c=((n+1)/2);
      for(int i=0;i

  • @Ad-pt2fk
    @Ad-pt2fk หลายเดือนก่อน +1

    awesome logic for pattern no. 22💥

  • @yogeshverma7366
    @yogeshverma7366 ปีที่แล้ว +4

    Hey Striver, for the pattern 18, I guess the code will not work for n > 5, it will start printing characters lesser than 'A'.

    • @varunsde9533
      @varunsde9533 11 หลายเดือนก่อน

      to make it as per any value of n, make the following changes: char ch = (char)((int)'A'+n-i-1); for(int j=0;j

  • @sarthakpatwari7988
    @sarthakpatwari7988 7 หลายเดือนก่อน

    The logic for last one is something out of the box, great work man!!

  • @YaswanthReddy-q3f
    @YaswanthReddy-q3f หลายเดือนก่อน +3

    if god choose to teach DSA it was striver

  • @simransatpute6972
    @simransatpute6972 วันที่ผ่านมา

    I think we should not hardcode 'E' in pattern 18, better implementation will be,
    void printPattern(int n)
    {
    for (int i = 0; i < n; i++)
    {
    //letters
    char ch = 'A' + n - i - 1;
    for (int j = 0; j

  • @raunakkumar2555
    @raunakkumar2555 8 หลายเดือนก่อน +1

    believe me I watched the petterns videos earlier from another youtubers too but I myself wasn't able to solve a single pattern but this time this person made me do the complex patterns by my self.He is something different .Hatss off to youu bhaiya

  • @ChetanRajput-ju2sd
    @ChetanRajput-ju2sd 7 หลายเดือนก่อน

    problem 22 - For Python:
    I found below approach most optimised.
    If u observe (row wise):
    1st half and 2nd half is a mirror (ignore middle for a while.)
    1st half of a row is a combination of two parts:
    a - fix part b - decremental part
    for eg , for n = 6 (considering just 1st half of a row)
    row1 : 666666 -> all fix , no decremental
    row2 : 655555 -> 6- decremental , 55555 - fix
    row3 : 654444 -> 65 - dec , 4444 - fix
    row4 : 654333 -> 654 - dec , 333 - fix
    derive the code for dec and fix , then combine the string to generate 1st part of a row , then neglet last character and reverse the result , concatenate both original and reverse to get full row.
    time difference (n = 500 )
    1. n - min() approach : 256ms
    2. above approach : 54 ms

  • @jayvardhanthorat7744
    @jayvardhanthorat7744 3 หลายเดือนก่อน +2

    Alternate Better Solution 54:42 :
    void Print17(int n)
    {
    for (int i = 1; i

  • @mintobit
    @mintobit 9 หลายเดือนก่อน

    As an alternative solution for pattern #22: every number equals to the distance from center + 1.
    private static void numberPattern(int n) {
    for (int i = -n+1; i < n; i++) {
    for (int j = -n+1; j < n; j++) {
    System.out.print(1 + Math.max(Math.abs(i), Math.abs(j)));
    }
    System.out.print("
    ");
    }
    }

  • @Sagardeep_Das
    @Sagardeep_Das 9 หลายเดือนก่อน

    For pattern 18 this can be tried too. It can print decreasing pattern for any no of alphabets (don't exceed n = 25 in input)
    void pattern18(int n)
    {
    int count = n;
    for(int i = 0; i

  • @amansinghrajput18
    @amansinghrajput18 5 หลายเดือนก่อน +1

    Understood..Great way of teaching

  • @pozo-r1x
    @pozo-r1x 3 หลายเดือนก่อน

    understood and finally complete this video and successfully done with all the patterns

    ⭐⭐
    ⭐⭐⭐
    ⭐⭐⭐⭐

  • @prasanna_2304
    @prasanna_2304 27 วันที่ผ่านมา +2

    In pattern 19 we can't assign space for the second part of the pattern it should be dynamic,
    public class Solution {
    public static void symmetry(int n) {
    int space = 0;
    for(int i =0;i

  • @Codeeater-vq2pz
    @Codeeater-vq2pz ปีที่แล้ว +1

    Patern 5 alternate approach
    void seeding(int n) {
    for(int i=1; i= i ; j- -){
    cout

  • @programmingwallah2905
    @programmingwallah2905 11 หลายเดือนก่อน +2

    One of the best man in coding community

  • @user-zy3mz6ml7c
    @user-zy3mz6ml7c 10 หลายเดือนก่อน

    You're answer for question 18 only gets correct answer when n is 5 because you hardcoded E into the for loop. The answer should be:
    void print18(int n){
    for (int i=0;i

  • @niranjanniru4115
    @niranjanniru4115 10 หลายเดือนก่อน +1

    BRO GUD TUTOR FOR DSA AND AS WELL AS FOR C++.....
    WE NEED MORE UPDATEZ LIKE THIX AND THANKS FOR YOUR LECTURE BRO

  • @saisameer780
    @saisameer780 3 หลายเดือนก่อน

    Thank you GOAT !!! Never understood patterns this good .

  • @nikhilmalhotra1986
    @nikhilmalhotra1986 4 หลายเดือนก่อน

    really glad a time you spent to explain this small topic in depth 🙂

  • @aksacts
    @aksacts 9 หลายเดือนก่อน +1

    39:22 tip for pattern 11:
    if the sum of every single (row+column) is 'even' then have to print 1 else 0
    if((i + j) % 2 === 0) print(1) else print
    @mehtabmulltani3194

  • @sanatwalia1432
    @sanatwalia1432 7 หลายเดือนก่อน

    Understood Everything . Your course is amazing !!!!

  • @NerdOverPhysics
    @NerdOverPhysics 4 หลายเดือนก่อน

    for pattern 18 it will always start from 'E'. Instead, we can code this way better :
    void pattern18(int n){
    char ch = 'A'+n;
    for(int i=0;i