Samsung interview question | minimum steps in infinite grid

Sdílet
Vložit
  • čas přidán 11. 06. 2019
  • This video explains a very interesting programming question which is frequently asked in programming interviews and coding rounds. The problem is given an infinite grid, we want to find the minimum number to steps to cover a given sequence of points in the order of the sequence itself. Code link is mentioned below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    CODE LINK: drive.google.com/open?id=1ZZP...

Komentáře • 27

  • @HimanshuSharma-tm2ms
    @HimanshuSharma-tm2ms Před 4 lety +7

    we are doing max(abs x diff, abs y diff) because we can always replace (1 move up + 1 move left) by a north west diagonal move and likewise for other diagonals , so our main concern is to cover the max diff which is in either along x coordinate or y coordinate , because the smaller of the differences can be covered by this diagonal move as it will count for an x move as well as for a y move in just one move !

  • @faisalrizwan2489
    @faisalrizwan2489 Před 4 lety +1

    Loved your solution. You got one more subscriber. Thanks!

  • @sakthim7160
    @sakthim7160 Před 4 lety +1

    Easy way to find minimum distance. Nice!

  • @padmajavepakomma8648
    @padmajavepakomma8648 Před 3 lety +1

    Excellent explanation brother and ur voice so nice and clarity

  • @israkulhaquetusher3256

    will you please provide me the problem link where i can submit ?

  • @sajalagarwal3486
    @sajalagarwal3486 Před 3 lety +2

    can you please explain why we used this formula? i mean any explanation behind using this approach. I got the solution but i didn't get it why we used this formula

    • @techdose4u
      @techdose4u  Před 3 lety

      This is simple math formula for grid.

  • @israkulhaquetusher3256

    Please add more samsung coding problems

  • @nimishabajpai6816
    @nimishabajpai6816 Před 3 lety +1

    Sir your logics are really awesome 👌👌

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd Před 3 lety +2

    Why you dont give us INTUTION first. CODE is Secondary! @TECH DOSE

  • @HarishAmarnath
    @HarishAmarnath Před 3 lety

    Ok for all those thinking why he used Manhattan distance instead of Euclidean distance..we are meant to calculate the no of grids he must go through..not the actual accurate distance.

  • @siddeshas8193
    @siddeshas8193 Před 3 lety +1

    i felt good but how can someone suddenly think abt this formula or equation is any other method please reply

    • @techdose4u
      @techdose4u  Před 3 lety +2

      This is very simple maths formula. Probably you should revise your distance formula for this.

    • @siddeshas8193
      @siddeshas8193 Před 3 lety

      @@techdose4uyes sir now I got it but in question if small change is like. To find maximum distance between the points how to do

    • @siddeshas8193
      @siddeshas8193 Před 3 lety

      @@techdose4u sir thank you for your reply that happy u reliped me fast

    • @HarishAmarnath
      @HarishAmarnath Před 3 lety

      He should be using the distance between two points formula distance = √ a2 + b2

    • @PandeyAvinesh
      @PandeyAvinesh Před 2 lety

      @@HarishAmarnath no that's euclidean formula we need to find total no. of grids or steps so we will be using manhattan distance formula for grids.

  • @srijaedupuganti9466
    @srijaedupuganti9466 Před 4 lety +1

    ummm i didnt get the intution

    • @18lakhvinder18
      @18lakhvinder18 Před 4 lety

      Same....the formula is not believable

    • @Amit_Kumar_1999
      @Amit_Kumar_1999 Před 4 lety +1

      Just Google "Manhatten Distance", this problem has nothing to do with any kind of algorithm or intuition.