Can you solve my favorite interview question? (math + cs)

Joma Tech

1,2 Tr lượt xem11 000

    📚 Video courses from JomaClass:
    🎓 New to programming? Learn Python here:
    🎓 Learn SQL for data science and data analytics:
    🎓 Data Structures and Algorithms:

    💵 Start Investing and get 2 FREE Stocks valued up to $1850 (when you deposit $100):

    ⭐ Support my channel to access my extra Videos/Vlogs:

    👕 Notvine Merch and Untitled Merch:

    💼 Resume Template and Cover letter I used for applying to software internships and full-time jobs:

    📰 Stay in touch with me through my weekly newsletter:

    📱 Social Media

    Xuất bản Năm trước


    1. Joma Tech

      Check out my second channel: for snackable educational content

      1. kunal kotiyal

        Please see samdoesart

      2. Thierry Mad

        What about the mass of the sun 🤷

      3. Alex Cerda

        Love this channel make moreeeeeee

      4. Sugam Pradhan

        @Abeer Rehan there are 4 square, so 4* r2 is correct also he considered calculation at once so (2*r )^2

      5. Kamil White

        It will be better if you will add something about Monte Carlo simulation. And add up quantum computing for Monte Carlo sim. Anyway great content, will be waiting for more

    2. Soumojit Chowdhury

      That logic of thinking with the graph is where the main clue is... Awesome idea

    3. POP

      I wonder what camera you use for recording your videos.

    4. Mehmet Aydın

      after saying "you fucking idiot" : 3:03 made my day xd

    5. Something Nothing

      Goes to Google and then Google searches Google to re go to Google. Lol

    6. Weyne Shea

      The Pi question is easy. Just need high school math.

    7. Ammar Mehmood

      i have a question , u didnt call the function , how is this gonna suppose to work

    8. Idea Spark

      I thank myself for dropping out of computer science engineering.

    9. El Conde de Toscana

      This guy is so stupid. What a mess he does talking for something so simple

    10. Rafi Alfarisi

      n = 10 res = 0 while res != 22/7: res = estimate_pi(n) n = n*10 return res jk

    11. Konson Heb

      I have no idea why Im watching this! WTF?!

    12. David Donadze


    13. Murray Pendergrass

      I have a masters degree in math and although I understand the answer easily I would have been unlikely to come up with that on my own in a short amount of time on the interview question. Awesome! My understanding is that random numbers are a difficult area of CS, of course the problem assumes a perfect RNG.

      1. Murray Pendergrass

        Would be curious to see an analysis of convergence as n grows

    14. Matias Kadorna

      Literalmente llore de la risa en el minuto 3:04

    15. Jon Lochan

      how am i now discovering you. this is the greatest content of all time.

    16. John Judith


      1. Duarte Goncalo

        earn from home don't allow the depletion of the economy affect you

      2. Duarte Goncalo

        Trading is the game on board now,

      3. Jenny Williams

        Tell him I referred you 👆👆👆

      4. Jenny Williams

        @ Expert_jacksonFX

      5. Jenny Williams

        T l e g r a m🖊️🖊️🖊️

    17. Kronic Gaming

      So, I completely understood what happened there an how you got, 3.145 or Pi ; why would you do this or why could it be useful is really my question?

      1. Pets

        You think interview questions are there to help you in the future?

    18. renny langat

      Why did he google google though lol

    19. Wicke 2D

      6:00 how did he copy the line without highlighting?

    20. Ivan Zaev

      Not good example for newby . You just need to know this solution in advance and how to solve these problems

    21. Omar EL HIMASS

      The secret of this algo is the random function that you should choose But this question in an interview is looking for Phytaghore, not looking for hiring someone

    22. Somogyi Benji

      Nice work bro...I like it

    23. tablet tablete

      3:03 LMAO!!!!

    24. T. J

      Joma Tech: "Oh you didn`t know? Fuckin' idiot" Also Joma Tech: Searches google for the area of a circle formula

    25. T. J

      i subscribed because you cursed at me @ 2:58 LMAO

    26. Marco Curvello

      num_point_total == n, so you don't need a separate variable =)

    27. Роман Пономаренко

      oh, i like that part where you open the google to search google search to search in the google search the python random...

    28. Nathan Black

      While watching your video I decided to rewrite your function using Node.js. The initial single-threaded version takes ~24 seconds to calculate an estimate of pi based on 10 million points. After that, I wrote a second version that uses worker threads. The difference? The multi-threaded version takes about the same 24 seconds to calculate the estimate for... 10 billion points :D That was a nice little exercise, thank you for the inspiration!

    29. E R Gui

      The kindly bail observationally cheat because feature compatibly cycle near a known criminal. wide-eyed, numerous cd

    30. justrajdeep

      really liked the video

    31. Sonjoy Nath

      The cowardly drum naturally count because epoxy hemperly disappear amid a hysterical radar. hard, ruddy tire

    32. Rian Gunawan

      i even dont know what is he talking about :"v

    33. Philip Ceperes

      You typed google. You search Google. And you click Google. That's what a managerial lvl IT enggr will do to prolonged their working hours without actually doing anything. Haha.

    34. Prasun De

      Classic example of Rejection Sampling !

    35. Abo

      Meanwhile Indian clz 11 students practising the similiar mathematical Q

    36. Rishabh Singh Pal

      Can someone give me the discord link

    37. kunal kotiyal

      Joma is just a deep copy of TechLead with modified sense of humour

    38. Steven Williams

      That is a fun interview question

    39. Дамир Имаев

      2:49 XD

    40. Łukasz Paluch

      Every exam question ever. (Talking about the comparision from the begining of the video) Except yours makes actual sense :D

    41. Pyzard

      I'm 11 years old, but surprisingly I understood the math.

      1. Pyzard

        @Liefwarrior Thank you.

      2. Liefwarrior

        Good job man!

    42. Ritul Singh

      And here you have the basic concept of DDA algorithm!

    43. B J

      5:25 to find Google so he can Google the formula...epic

    44. BIGcoxMAN

      Joma's sarcasm is on par with techleads.

    45. dgory

      import numpy as np def estimate_pi(n): return (4*np.mean( np.linalg.norm( np.random.rand(n, 2), axis=1) < 1))

    46. Daniel Catalan

      2:33 RIP replay button for that "Ngyaaw"

    47. Bruno Marques

      that google search to search google made me laugh more than it should lol

    48. Arpit Tripathi

      Searching google on google before you search 💯

    49. Leo Hedrick

      No one saw that my dude Googled how to get the area of the circle?

    50. TheRocker3011

      There is a mistake in the code x**2 + y**2 can be bigger than 1, take 0.9 for example in both x and y and you will see. Then again a dude like this sees a mistake like that in an interview and he will reject you but he makes the same mistake on a youtube video and it is fine, that is why I feel interviews should be way less picky but whatever you do you

    51. Scythe

      interestingly, the only thing about this interview I knew without googling was that the area of a circle is calculated by r²π or d²π/4 I see how the question shows how you tackle a problem but it still seems very artificial and an unrealistic scenario that wouldn't happen during work.

    52. Edson Archela

      Is total aways equal to n. Yes it's

      1. Edson Archela

        great question. Great video!!!

    53. EFormance Engineering

      I can see this as being a useful way to test RNG data sources, the closer they get to pi, the more random they are.

    54. jacob d davis

      "oh you didnt know, fucking idiot" proceeds to search "what is area of circle on google"

    55. CR3AMYN3LL

      That's really an interesting question

    56. shresth gupta

      bro i like your searching style lol you are awesome bro :)

    57. ATIF ADIB

      1:45 3b1b: Lets add clicking noises, Joma: pew pew de pew pew pew.

    58. Simone Micucci

      Is more efficient using fixed parameter and it give back a better approximation of pi😅

    59. Bryan Pérez

      Put subtitles, please.

    60. Anirudh Korapole

      I lost it when he started using REPL in Light mode

    61. Juan Felipe Matajira

      I had that question in a interview. Piece of cake! Altough it took to me 1 week to solve it :(

    62. nwstraith

      return Math.PI; GG

    63. Epik Man

      5:03 "How many points are in the Toto"

    64. nkhairil

      I don’t understand a single shit but keep watching because it seems entertaining and educational 🤣😂

    65. DRU

      I was forced out of school by an accident that wasn't my fault. Can you point me to a good program that can teach me math from the ground up? Not addition/subtraction etc.... Starting high school level.

    66. Michael K

      The thumbnail spoiled the solution for me... Nice video though

    67. Mr. Luke

      40 k of nerds

    68. Ahmad D. Y. Nugroho

      This dude use vim but doesn't use vimium lol

    69. Beyefendi Gagavuz

      Man, your math tasks sound exactly like we had in our math's books in Russian Middle schools back in the days

    70. YDK Baby

      Caught lackin in 4K

    71. Another number

      I don't see how a question like this has any bearing on how good somebody is at being a software engineer. It just seems like giving somebody a weird question to mess with them. I'd just go interview somewhere else.

    72. Michael Paoli

      Well this is what I did: $ expand -t 4 < piR #!/usr/bin/perl $^W=1; use strict; # Estimate pi, using only rand(1) and arithmetic # rand(1) give random number in range [0,1) # unit circle radius r has area pi(r)**2=pi # inscribe said circle inside square, square has area (2r)**2=4 # using rand(1) place points randomly within square # on average pi/4 * points will be on/within circle # points=p, i=on/in circle, p*pi/4=i # pi=4i/p # x=2*rand(1)-1 # y=2*rand(1)-1 # in/on circle? xx+yy

    73. bioches

      Why did he need to import random tho?

    74. Whoa Nelly

      Will this solve the endless spinning circle when windows goes TU? Nope.

    75. 郑一亿

      So... how do you calculate the mass of the sun?

    76. kolbstar

      Honestly, this is a pretty dumb question, IMO. I'm surprised you like it, let alone love it. I knew the answer because I just know about these ridiculous processes work, but I absolutely hate any question that does something like "pretend you don't know X; now answer Y." I would say that you failed your own interview question in this regard also. You told us all we have a function that generates uniform random variables. You didn't tell us we have proved the real line exists. You didn't tell us we've proven there's a function that provides solutions to a = x*x. You never proved that the area of a circle is pi*r*r. And I have my doubts that you can prove any of these things. So instead, you just imply "pretend you don't know anything except things that are obvious to me." It's a great way to ensure you only hire people less intelligent than you, I guess. But it's not a good question by any means.

    77. Kyren Eaddy

      He made it so easy to understand

    78. Dionissios Deonas


    79. Shane Welcher

      Forgive me, I am just learning. I am using Pycharm, it gives me a value of 4 when I print this. Here is the code I used. import random def estimate_pi(n): num_point_circle = 0 num_point_total = 0 for _ in range(n): x = random.uniform(0, 1) y = random.uniform(0, 1) distance = x**2 + y**2 if distance

    80. Никита Хеккер

      Кто такой Кувшинов Илья?))

    81. Pherecydes

      As soon as he asked the question I instantly knew how to do it. Now I'm disappointed that a million people have seen this and no one will be impressed if I correctly answer the question.

    82. Smit Raichura

      Please make a series of these type of questions

    83. Hyde 88

      If the question is that the random function generates values between 0 and 1 then all the points should then lie between (0,0) to (1,1) in which case the area of the square should be just r^2 and not (2.r)^2??

    84. Damon Bennett

      real og for the 'your name' wallpaper

    85. PhoenixMoonbeam

      It's almost always worth thinking about what the time complexity of it is.

    86. Zikora Agbapu

      That Rihanna joke is sublime.

    87. Bert0lutschi

      You have the exact same desktop background as I have in this video :D Kimi no na wa ist just too beautiful!

    88. Prakhar Tiwari

      did he just Google “google”?

    89. shuhan zhang

      I smashed subscribe cuz he said “fucking idiot “

    90. Madushan Jayawardane

      Ok, now calculate the mass of the sun.

    91. Chillicrab

      Import random... Ahh why didn't I think of that? It was so random.

    92. adi87

      As soon as I heard the problem, I yelled Monte Carlo haha

    93. Yazan Senjab

      HAHAHAHAHAHHA I died when I saw that he googled it

    94. Ace

      3:00-3:05 LMAOOO

    95. mohamed alikib javeed

      Hey @joma tech the discord link provided is invalid.. can you please share if you have a updated one

    96. Emanuele Troiani

      I don't think anyone would ask this question in a real interview, it's extremely basic. Anyone who took a probability class, even a high school level one, can solve it

    97. Jeremy Arancio

      Monte Carlo method

    98. Alberto Z.

      Love your sense of humor 😅👍 Great video, as usual 😊

    99. Adam Brown

      Wouldn’t they ask about the time complexity for n digits in an interview?

    100. Kelvin Victor De Souza

      Wow!! Very nice!" I didn't know that!!!