-
Notifications
You must be signed in to change notification settings - Fork 0
/
HLD-LLD_notes+DSA
2000 lines (1363 loc) · 91.8 KB
/
HLD-LLD_notes+DSA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
LHack
https://leetcode.com/twitch_tv_qiqi_impact/
1 thousand = 10^3 = 1000 = 1 KB
1 Million = 10^6 = 1000 * 1000 = 1 MB = 1000 kB
1 Billion = 10^9 = 1000 * 1000 * 1000 = 1 GB = 1000 MB
1 Trillion = 10^12 = 1000 * 1000 * 1000 * 1000 = 1 TB = 1000 GB
1 Quadrillion = 10^15 = 1 PB = 1000 TB
9631691275 —
Binary Number addition, sub, mul and division- https://www.youtube.com/watch?v=-f6fjBhu8eA
——————————————————————————————————————————————————————————————————————————————————————————————————————
Technology
How the web works?
Your system(type domain name) -> your router(wifi/lan) -> ISP(Ji/Airtel) -> DNS (root-level/top level etc ->returns server IP address
You make another request with IP address to get the desired website/data from server.
World is connected both wired and wireless.
Your ISP has a powerful router in your locality, from there it distributes to various houses, every connection does not come directly from ISP.
Various continents and countries are connected to each other using optical fibres under the sea.
Now digging dipper how data from server flows to ur machine
Your machine is connected to your router, which is connected to some local ISP providers like jio/act/hathway etc, then it is connected to Regional ISP(managed by government, canblock domains)----->
# Memcached Learning
Memcached Architecture- Hussein Nasser
https://youtu.be/NCePGsRZFus
https://medium.com/@SkyscannerEng/journey-to-the-centre-of-memcached-b239076e678a
Scaling Memcaced at Facebook
https://youtu.be/m4_7W4XzRgk
Memcaced SpringBoot
https://youtu.be/CBHVrdlvCTE
https://www.quora.com/How-does-a-Memcache-cluster-work-Say-Ive-5-nodes-in-my-cluster-and-I-issue-a-multi-get-Further-assume-that-size-of-response-of-multi-get-is-very-large
See chatgpt SQL chats
#Multithreading
Happens before guarantee
https://www.geeksforgeeks.org/happens-before-relationship-in-java/
Sync vs lock
https://stackoverflow.com/questions/4201713/synchronization-vs-lock
# JAVA 8 concepts
https://stackoverflow.com/questions/48183999/what-is-the-difference-between-putifabsent-and-computeifabsent-in-java-8-map
# Health Check Endpoint Migration Uber HLD
https://www.youtube.com/watch?v=akSbpOZ1dFA
# Design a real time dashboard showing the most played songs, Top K Trending Hashtags
https://leetcode.com/discuss/interview-question/system-design/243604/Design-a-real-time-dashboard-showing-the-most-played-songs
https://mecha-mind.medium.com/system-design-top-k-trending-hashtags-4e12de5bb846
https://medium.com/p/76ab433d93de/edit
https://www.youtube.com/watch?v=kx-XDoPjoHw
# Map Reduce
https://www.youtube.com/watch?v=cHGaQz0E7AU
https://static.googleusercontent.com/media/research.google.com/en//archive/mapreduce-osdi04.pdf
Real world examples-
https://www.youtube.com/watch?v=2sZ2M4gM-Kc
# SQL
Subqueries
https://www.youtube.com/watch?v=nJIEIzF7tDw
leetcode, hackerrank practice
# Docker & Kubernetes
Secret management
https://stackoverflow.com/questions/73822421/where-does-kubectl-create-secret-generic-name-from-literal-key1-value1-sav
https://snyk.io/blog/best-practices-for-kubernetes-secrets-management/
# Consistent Hashing
https://www.toptal.com/big-data/consistent-hashing
Cassandra- https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/types-of-databases
# Efficient querying on the data lake, avro format, parquet format, GRAB engineering blog
https://engineering.grab.com/enabling-near-realtime-data-analytics?utm_source=blog.quastor.org&utm_medium=newsletter&utm_campaign=the-architecture-of-grab-s-data-lake
——————————————————————————————————————————————————————————————————————————————————————————————————————
LLD
Difficult to follow lld codes by Gaurav sen- https://github.com/InterviewReady/Low-Level-Design/blob/main/rate-limiter/src/test/java/RateLimitTest.java
Anomaly- Udit aggarwal LLD- https://github.com/anomaly2104/anomaly2104
Tech granth LLD- https://github.com/TheTechGranth/thegranths/blob/master/src/main/java/DesignPatterns/Decorator/Caramel.java
Shadow Bird design patterns- https://github.com/shabbirdwd53/design_patterns/blob/main/observer/src/main/java/com/dailycodebuffer/observer/NewsAgency.java
# Rate Limiter
https://youtu.be/SgEDKN7ZjMw?si=TIV3uitlP-ghTZm9
https://youtu.be/X3G8gdh9GKE?si=rjruSZd2zit3TiUr
https://youtu.be/nxraKcWpBvs?si=CGzULaZOOH29sRsZ
https://youtu.be/X5daFTDfy2g?si=MioJL4jFQ-pAB7pN
easy to understand-Better Dev With Anubhav
https://www.youtube.com/watch?v=PJ-c0QI-QCk&t=756s
rate limiter - LLD - https://github.com/arpan-banerjee7/system-design-notes/tree/main/LLD/src/atlassian/ratelimiter/tokenbucket ——> GITHUB
for hld see educative
# Movie booking system
// Udit aggarwal youtube
https://www.youtube.com/watch?v=WwNw6WWTX70
https://varunkruthiventi.medium.com/distributed-locking-with-redis-af4e7d80b503
# Other references, including HLD
https://www.youtube.com/watch?v=qsGcfVGvFSs&t=1s
# Messaging/chat application/ SLACK
https://www.youtube.com/watch?v=Nt_gWiPMzNM&t=1s
https://www.reddit.com/r/Database/comments/wvrpc4/database_schema_for_private_chat_and_group_chat/
# Online Judge/ coding contest
https://medium.com/@saisandeepmopuri/system-design-online-judge-with-data-modelling-40cb2b53bfeb
https://medium.com/@yashbudukh/building-a-remote-code-execution-system-9e55c5b248d6
https://github.com/budukhyash/remote-code-execution-engine
https://documenter.getpostman.com/view/11156949/Szt8fAgW?version=latest#f60299e5-7f92-49bc-a6d4-d04410ef3175
# snake and ladder-
https://www.youtube.com/watch?v=UYb3DWyZ7-o
# parking lot-
https://drive.google.com/file/d/1cDLJQA4_RiqE5d2cCekhpTuVfLDnT_o0/view
# Association (Composition(string-has-a) vs Aggregation(weak-has-a))
https://stackoverflow.com/questions/885937/what-is-the-difference-between-association-aggregation-and-composition
https://opensourceforgeeks.blogspot.com/2014/11/difference-between-association.html
# has-a vs uses-a vs is-a
https://www.scientecheasy.com/2021/02/class-relationships-in-java.html/#google_vignette
# unidirectional vs bi-directional relationships in java and hibernate
https://www.baeldung.com/jpa-hibernate-associations#:~:text=Unidirectional%20and%20bidirectional%20associations%20in%20object%2Doriented%20programming%20differ%20in,a%20relationship%20in%20both%20directions
# Food delivery, zomato sqiggy
https://github.com/mayankbansal93/lld-food-delivery-zomato-swiggy/tree/origin/master
https://github.com/ashishps1/awesome-low-level-design/blob/main/problems/food-delivery-service.md
# Design in-memory file system UBER
https://leetcode.com/discuss/interview-experience/2716244/Uber-LLD
https://algo.monster/liteproblems/588
https://medium.com/root-node/design-in-memory-file-system-96ee6c484616
# Cult fit, fitness tracking application, set goals, track activities and nutrition
DB schema
https://www.geeksforgeeks.org/how-to-design-a-database-for-health-and-fitness-tracking-applications/
Chatgpt libnk- https://chatgpt.com/share/67553b35-3644-8008-a7b4-51d7dc8ea632
# Design Rule Engine- DateTime repo local.
Write code that will be used by a Shopping cart service to enforce rules on the order
eg.
Offer free 2 day shipping on orders > $35 if customer is not a prime member
Offer free 2 day shipping on all orders if customer is a prime member
Offer free 1 day shipping for order that are > $125
Offer free 2 hour shipping for prime customer that have > $25 and the items are grocery items
Make this extensible to add other rules in the future
Apply a 10% discount if an item has been marked for subscribe and save
https://youtu.be/eKU_hp7w3QI?si=9OsA-y3_WeoOr_63
Conditions and actions set from config/external uI
https://www.youtube.com/watch?v=BL27Qb0E4eE&list=PLCUIneK0ruzKX8uJafA81FOwn6FGeORwU&index=2
Gaurav Sen example- https://github.com/InterviewReady/turn-based-game-ai/blob/main/src/main/java/api/RuleSet.java
Bike rental LLD- https://chatgpt.com/share/67568e16-4660-8008-bbb1-d7aa00a35283
———————————————————————————————————————————————————————————————————————————————————————————————————
HLD
https://youtu.be/mhUQe4BKZXs?si=1rbgPHlXzAgj5rIk
# Pagination Offset vs Keyset/cursor pagination
https://use-the-index-luke.com/no-offset
https://www.reddit.com/r/programming/comments/knlp8a/stop_using_offset_for_pagination_why_its_grossly/
https://ignaciochiazzo.medium.com/paginating-requests-in-apis-d4883d4c1c4c
https://leetcode.com/discuss/interview-question/4200830/Atlassian-System-design%3A-Tagging-system/
https://systemdesign.one/system-design-interview-cheatsheet/#tagging-service
https://stackoverflow.com/questions/55744926/offset-pagination-vs-cursor-pagination
https://dev.to/jackmarchant/offset-and-cursor-pagination-explained-b89
Design Uber- https://www.youtube.com/watch?v=R_agd5qZ26Y
Design notification system- https://www.codekarle.com/system-design/Notification-system-design.html
https://www.youtube.com/watch?v=C6HHmH6wwMs (better)
Design tinyurl- https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/requirements-of-tinyurls-design
Design google docs- https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/requirements-of-tinyurls-design
Design google file system- https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/concurrency-in-collaborative-editing
Other designs- https://systemdesign.one/system-design-interview-cheatsheet/#tagging-service
Design Key value store- https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/concurrency-in-collaborative-editing
Design sequencer- https://medium.com/me/stories/drafts
Design top k frequent hashtags/songs/ or anything — https://medium.com/me/stories/drafts
Design Whatsapp- https://www.codekarle.com/system-design/Whatsapp-system-design.html
Design newsfeed system-
https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers/design-of-a-newsfeed-system
Short-
https://youtu.be/gbysuvl2TZo?si=b7e5J-cJ2MH5k8mT
https://youtu.be/zFupwVz7JxY?si=9wzGiwNB09TOVSAt
Best-
https://www.youtube.com/watch?v=nWp9PScmd_Q
Linkedin s feed infrastructure- side read- https://rockset.com/index-conf/Index24_Linkedin.pdf
Facebook video live comments-
https://www.hellointerview.com/learn/system-design/answer-keys/fb-live-comments
https://www.youtube.com/watch?v=tgSe27eoBG0
https://systemdesign.one/live-comment-system-design/#fn:15
https://www.infoq.com/presentations/linkedin-play-akka-distributed-systems/
Facebook live video-
https://newsletter.systemdesign.one/p/live-streaming-architecture?utm_source=post-email-title&publication_id=1511845&post_id=144760801&utm_campaign=email-post-title&isFreemail=true&r=1fhrl8&triedRedirect=true&utm_medium=email
* Scaling Facebook Live
* Scaling Facebook Live-2
* Scaling Facebook Live Videos to a Billion Users
* Sachin Kulkarni Describes the Architecture behind Facebook Live
* Under the hood: Broadcasting live video to millions
* Live video solutions: Solving the thundering herd problem
* Adaptive Bitrate Streaming
* Understanding Request Coalescing
* Tham Luang cave rescue
Cron Job running at many intervals in a day to reduce peak server load-
https://interviewready.io/blog/concurrency-for-senior-engineers-part-ii
https://interviewready.io/learn/system-design-course/google-docs-collaborative-editor-design/Avoiding-Thundering-Herds-in-Crons
The cron job uses the modulo operation (USER_ID % 48) to assign users to one of the 48 intervals. The result of this operation gives you an INTERVAL_ID ranging from 0 to 47.
Assume you have users with USER_IDs from 1 to 80,000.
* The day is divided into 48 intervals.
For interval 0:
* The cron job runs and identifies users where USER_ID % 48 == 0.
* This means users with USER_IDs like 48, 96, 144, ..., up to 79,968 will receive emails in this interval.
For interval 1:
* The cron job runs and identifies users where USER_ID % 48 == 1.
* This means users with USER_IDs like 1, 49, 97, ..., up to 79,969 will receive emails in this interval.
Different types of failures in microservices
Doordash blog- https://doordash.engineering/2023/03/14/failure-mitigation-for-microservices-an-intro-to-aperture/?utm_source=blog.quastor.org&utm_medium=newsletter&utm_campaign=scaling-microservices-at-doordash
Production failure— Doordash kubernetes rediness probe failure resulting in outage
https://doordash.engineering/2022/08/09/how-to-handle-kubernetes-health-checks/
Request collapsing, request hedging, cron job
https://interviewready.io/blog/concurrency-for-senior-engineers-part-iii
https://interviewready.io/blog/Concurrency-Patterns-for-Senior-Engineers-part-1
Request collapsing code
https://github.com/InterviewReady/Low-Level-Design/blob/main/distributed-cache/src/main/java/Cache.java#L76
SLACK HLD
https://slack.engineering/flannel-an-application-level-edge-cache-to-make-slack-scale/
https://systemdesign.one/slack-architecture/
https://www.linkedin.com/pulse/slack-system-design-surya-narayana-senqc/
https://scaleyourapp.com/system-design-case-study-real-time-messaging-architecture/
https://github1s.com/anshriva/redis-web-sockets-chat/blob/master/src/main/java/com/anubhav/redis/SubscriberHelper.java
Design DROPBOX
https://newsletter.systemdesign.one/p/dropbox-architecture?utm_source=post-email-title&publication_id=1511845&post_id=142574656&utm_campaign=email-post-title&isFreemail=true&r=1fhrl8&triedRedirect=true&utm_medium=email
How Booking.com scaled their Customer Review System
consistent hashing, redistribution of data without downtime
adding new shards to scale the system
https://mail.google.com/mail/u/0/#inbox/FMfcgzQVxbjQWCPXxDZJscHTFZWXzbrS
https://medium.com/booking-com-development/scaling-our-customer-review-system-for-peak-traffic-cb19be434edf
https://www.youtube.com/watch?v=BFyWl9MNDjY
The resharding process described here is a bit complex, but it's designed to minimize downtime and ensure data consistency. Here is a detailed explanation:
1. Provisioning and Loading: New shards (nodes) are provisioned. The coordinator nodes determine which keys will be remapped (moved) to these new shards. The new shards load these keys but the keys are not yet deleted from the old shards.
2. Resharding: The process of transferring the keys from the old shards to the new ones begins. The important thing to note here is that during this process, the keys that are being moved are still available on the old shards. This ensures that the data is still accessible during the resharding process, which might take some time depending on the size of the data.
3. Routing: The routing layer, unaware of the ongoing resharding, continues to direct traffic (both read and write requests) to the old shards. This means that even if new data is added (in your case, new reviews), it will still be directed to the old shards.
4. Completion and Updating: Once the resharding process is complete, the routing layer is updated and begins directing traffic to the new shards. At this point, the keys that were moved can be deleted from the old shards.
Your concern about new data being continuously added to the old shards during the resharding process is valid. However, this is typically handled by running the resharding process at a time when the write load is minimal, or by pausing writes briefly. For a review system with an 80:20 read-to-write ratio, this might be less of a concern as the majority of the traffic is read requests.
Remember that the goal of this process is to maintain high availability and data consistency during the resharding process. By keeping the routing layer unaware of the resharding process until it's complete, it ensures that all data - old and new - is available and consistent, even if it's distributed across multiple shards.
Design flash sale
High contention limited resources(for update) [skip locked]
Basically two major approaches are there.
Count of inventory + user to item mapping ( separate on the fly)
(n items for sale in one table) —> separate out initially
SDFC
https://systemdesignfightclub.com/flash-sale/
https://github.com/systemdesignfightclub/SDFC/blob/main/system-design/flash-sale/flash-sale-textfile.md
Anubhav
https://www.youtube.com/watch?v=462JSRNPDNs
https://www.youtube.com/watch?v=EUV-m9x5pVo
https://www.reddit.com/r/leetcode/comments/zbge4a/design_flash_sale_high_concurrency_system_design/
LLD problem statement
https://leetcode.com/discuss/interview-question/system-design/1734666/system-design-online-interview-design-a-limited-time-deals
Arpit Bhayani
https://github.com/systemdesignfightclub/SDFC/blob/main/system-design/flash-sale/flash-sale-textfile.md
How notion made page loads faster by using wasm sqlite for client side caching?
https://www.notion.so/blog/how-we-sped-up-notion-in-the-browser-with-wasm-sqlite?utm_source=blog.quastor.org&utm_medium=newsletter&utm_campaign=how-notion-decreased-latency-by-20-with-caching&_bhlid=5a612757905a6e9e23c0a9c7a3d32ad8342e474a
Redis use cases
https://www.youtube.com/watch?v=5jwuDM6Z3F8
Design live leaderboard, design my11circle, fantasy cricket app
https://www.youtube.com/watch?v=1xHADtekTNg
Hello interview design leetcode, online coding contest
How @twitter keeps its Search systems up and stable at scale
https://www.youtube.com/watch?v=dOyCq_mMtdI
used Elastic search, Reads are synschronous and made directly to elastic search, writes are deffered.
Realtime writes through proxy—> kafka—> workers to elastic search
Backfilling, instead of map readuce jobs directly updating ealstic search index, puts into HDFS—> consumers/workers->elastic search
How Robinhood uses Graph Algorithms to prevent Fraud
email subject
https://newsroom.aboutrobinhood.com/preventing-fraud-at-robinhood-using-graph-intelligence/?utm_source=blog.quastor.org&utm_medium=newsletter&utm_campaign=how-robinhood-uses-graph-algorithms-to-prevent-fraud&_bhlid=cd3f346495fa56ab560397a18af5a85fad14490b
——————————————————————————DSA—————————————————————
Next closest time- https://www.youtube.com/watch?v=OndJpimZorQ
Garipuk@9879
673219
- [x] https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/
https://leetcode.com/problems/word-ladder/
- [x] https://www.hackerrank.com/contests/test-your-skills-in-linked-list/challenges
https://www.geeksforgeeks.org/sort-k-sorted-doubly-linked-list/
https://www.codingninjas.com/codestudio/problems/sort-a-k-sorted-doubly-linked-list_1118118?leftPanelTab=0
https://www.youtube.com/watch?v=dYfM6J1y0mU
https://practice.geeksforgeeks.org/problems/merge-two-sorted-linked-lists/1#
- [x] 318. Maximum Product of Word Lengths
Java Hashmap- https://leetcode.com/problems/maximum-product-of-word-lengths/discuss/1234661/Java-%2B-HashMap-Concise-solution
Bit Msk- https://leetcode.com/problems/maximum-product-of-word-lengths/discuss/2085333/Short-Bitmask-Solution-(explained)-or-JAVA
Knowledge center- https://www.youtube.com/watch?v=E8Ctj36CzuY
278. First Bad Version
https://leetcode.com/problems/first-bad-version/
752. Open the Lock
https://leetcode.com/problems/open-the-lock/
1658. Minimum Operations to Reduce X to Zero
https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero/
1423. Maximum Points You Can Obtain from Cards
https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/
Minimise the maximum difference between adjacent elements in an array
https://www.geeksforgeeks.org/minimize-the-maximum-difference-between-adjacent-elements-in-an-array/
665. Non-decreasing Array
https://leetcode.com/problems/non-decreasing-array/
1124. Longest Well-Performing Interval
https://leetcode.com/problems/longest-well-performing-interval/
462. Minimum Moves to Equal Array Elements II
https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/
1696. Jump Game VI
https://leetcode.com/problems/jump-game-vi/
Sahil Graph series
997. Find the Town Judge
https://leetcode.com/problems/find-the-town-judge/
547. Number of Provinces
https://leetcode.com/problems/number-of-provinces/
733. Flood Fill
https://leetcode.com/problems/flood-fill/
1254. Number of Closed Islands
boundary dfs
https://leetcode.com/problems/number-of-closed-islands/
130. Surrounded Regions
boundary dfs
https://leetcode.com/problems/surrounded-regions/
Count Inversions
https://practice.geeksforgeeks.org/problems/inversion-of-array-1587115620/1
Striver- https://www.youtube.com/watch?v=kQ1mJlwW-c0&t=687s
775. Global and Local Inversions
https://leetcode.com/problems/global-and-local-inversions/
315. Count of Smaller Numbers After Self
https://leetcode.com/problems/count-of-smaller-numbers-after-self/
916. Word Subsets
https://leetcode.com/problems/word-subsets/
560. Subarray Sum Equals K
https://leetcode.com/problems/subarray-sum-equals-k/
Delete Blocks of Linked List
https://www.hackerrank.com/contests/weekly-coding-contest-linked-list/challenges/delete-blocks-of-linked-list/problem
Delete continuous nodes with sum K from a given linked list
https://www.geeksforgeeks.org/delete-continuous-nodes-with-sum-k-from-a-given-linked-list/
1171. Remove Zero Sum Consecutive Nodes from Linked List
https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/
https://www.youtube.com/watch?v=oyPFsOWTXws
Delete Blocks of Linked List
https://www.hackerrank.com/contests/weekly-coding-contest-linked-list/challenges/delete-blocks-of-linked-list/problem
Subarrays With Zero Sum
https://www.codingninjas.com/codestudio/problems/subarrays-with-zero-sum_3161876?leftPanelTab=0
658. Find K Closest Elements
https://leetcode.com/problems/find-k-closest-elements/
https://www.swagwaladeveloper.com/s/courses/61dd712c0cf2008e689e6df0/take
33. Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/
81. Search in Rotated Sorted Array II
https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
153. Find Minimum in Rotated Sorted Array
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
374. Guess Number Higher or Lower
https://leetcode.com/problems/guess-number-higher-or-lower/
69. Sqrt(x)
https://leetcode.com/problems/sqrtx/
35. Search Insert Position
https://leetcode.com/problems/search-insert-position/
34. Find First and Last Position of Element in Sorted Array
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
2089. Find Target Indices After Sorting Array
https://leetcode.com/problems/find-target-indices-after-sorting-array/
1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance
https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/
743. Network Delay Time
https://leetcode.com/problems/network-delay-time/
1105. Filling Bookcase Shelves
https://leetcode.com/problems/filling-bookcase-shelves/
336. Palindrome Pairs
https://leetcode.com/problems/palindrome-pairs/
112. Path Sum
https://leetcode.com/problems/path-sum/
113. Path Sum II
https://leetcode.com/problems/path-sum-ii/
16. 3Sum Closest
https://leetcode.com/problems/3sum-closest/description/
472. Concatenated Words
https://leetcode.com/problems/concatenated-words/description/
Alice String Game
https://www.hackerrank.com/contests/weekly-coding-contest-stackqueue-1665844111/challenges/alice-string-game/problem
909. Snakes and Ladders
https://leetcode.com/problems/snakes-and-ladders/description/
Neetcode- https://www.youtube.com/watch?v=6lH4nO3JfLk
Leetcode own post- https://leetcode.com/problems/snakes-and-ladders/solutions/2725693/java-solution-1d-array-adjacency-list-bfs/
Related prob- https://www.hackerrank.com/challenges/the-quickest-way-up/problem
Subarray sum 0
https://www.pepcoding.com/resources/data-structures-and-algorithms-in-java-levelup/hashmap-and-heaps/count_of_all_subarrays_with_zero_sum/topic
Subarray Sum equals K
https://leetcode.com/problems/subarray-sum-equals-k/
523. Continuous Subarray Sum
https://leetcode.com/problems/continuous-subarray-sum/description/
Neetcode- https://www.youtube.com/watch?v=OKcrLfR-8mE
465 - Optimal Account Balancing/ Splitwise algorithm
https://leetcode.ca/2017-03-09-465-Optimal-Account-Balancing/
Settle Debt
https://www.codingninjas.com/codestudio/problems/settle-debt_1232658?leftPanelTab=2
Debt Paid
https://www.hackerrank.com/contests/coding-test-backtracking/challenges/debt-paid
Solution- https://www.youtube.com/watch?v=WaUlOC1T07c
279. Perfect Squares
https://leetcode.com/problems/perfect-squares/description/
907. Sum of Subarray Minimums
https://leetcode.com/problems/sum-of-subarray-minimums/submissions/849579275/
https://www.youtube.com/watch?v=9-TXIVEXX2w
// [3,4,4,5,4,1]
413. Arithmetic Slices
https://leetcode.com/problems/arithmetic-slices/description/
446. Arithmetic Slices II - Subsequence
https://leetcode.com/problems/arithmetic-slices-ii-subsequence/description/
https://www.youtube.com/watch?v=XjLT4TaXsgw
1657. Determine if Two Strings Are Close
https://leetcode.com/problems/determine-if-two-strings-are-close/description/
string, subsequence
392. Is Subsequence
https://leetcode.com/problems/is-subsequence/?envType=daily-question&envId=2023-09-22
string, subsequence
1289. Minimum Falling Path Sum II
https://leetcode.com/problems/minimum-falling-path-sum-ii/description/
1774. Closest Dessert Cost
https://leetcode.com/problems/closest-dessert-cost/description/
739. Daily Temperatures
https://leetcode.com/problems/daily-temperatures/description/
980. Unique Paths III
https://leetcode.com/problems/unique-paths-iii/description/
290. Word Pattern
https://leetcode.com/problems/word-pattern/description/
1277. Count Square Submatrices with All Ones
https://leetcode.com/problems/count-square-submatrices-with-all-ones/description/
2244. Minimum Rounds to Complete All Tasks
https://leetcode.com/problems/minimum-rounds-to-complete-all-tasks/description/
452. Minimum Number of Arrows to Burst Balloons
https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/
Find the middle of a given linked list
https://www.geeksforgeeks.org/write-a-c-function-to-print-the-middle-of-the-linked-list/
1224. Maximum Equal Frequency
https://leetcode.com/problems/maximum-equal-frequency/description/
1519. Number of Nodes in the Sub-Tree With the Same Label
https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/description/
2246. Longest Path With Different Adjacent Characters
https://leetcode.com/problems/longest-path-with-different-adjacent-characters/submissions/877677634/
1061. Lexicographically Smallest Equivalent String
https://leetcode.com/problems/lexicographically-smallest-equivalent-string/submissions/878193907/
// bipartite graph, lcs question
// https://www.youtube.com/watch?v=nrIBmbS2zlk
D - Collision
https://atcoder.jp/contests/abc209/tasks/abc209_d
Akbar's Kingdom
https://www.hackerrank.com/contests/weekly-test-graph/challenges/akbars-kingdom/problem
1472. Design Browser History
https://leetcode.com/problems/design-browser-history/description/
735. Asteroid Collision
https://leetcode.com/problems/asteroid-collision/description/
926. Flip String to Monotone Increasing
https://leetcode.com/problems/flip-string-to-monotone-increasing/description/
918. Maximum Sum Circular Subarray
https://leetcode.com/problems/maximum-sum-circular-subarray/description/
Similar to kadanes algo(applied with global min)
456. 132 Pattern
https://leetcode.com/problems/132-pattern/description/
1443. Minimum Time to Collect All Apples in a Tree
https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/description/
491. Non-decreasing Subsequences
https://leetcode.com/problems/non-decreasing-subsequences/description/
93. Restore IP Addresses
https://leetcode.com/problems/restore-ip-addresses/description/
Same as palindrome partitioning
131. Palindrome Partitioning
https://leetcode.com/problems/palindrome-partitioning/
2359. Find Closest Node to Given Two Nodes
https://leetcode.com/problems/find-closest-node-to-given-two-nodes/description/
1071. Greatest Common Divisor of Strings
https://leetcode.com/problems/greatest-common-divisor-of-strings/description/
904. Fruit Into Baskets
https://leetcode.com/problems/fruit-into-baskets/description/
Sliding window
2187. Minimum Time to Complete Trips
https://leetcode.com/problems/minimum-time-to-complete-trips/
Binary search(ceil) upper bound range based bs
many questions on this pattern
567. Permutation in String
https://leetcode.com/problems/permutation-in-string/
652. Find Duplicate Subtrees
https://leetcode.com/problems/find-duplicate-subtrees/
2444. Count Subarrays With Fixed Bounds
https://leetcode.com/problems/count-subarrays-with-fixed-bounds/description/
958. Check Completeness of a Binary Tree
https://leetcode.com/problems/check-completeness-of-a-binary-tree/description/
2360. Longest Cycle in a Graph
https://leetcode.com/problems/longest-cycle-in-a-graph/description/
983. Minimum Cost For Tickets
https://leetcode.com/problems/minimum-cost-for-tickets/description/
871. Minimum Number of Refueling Stops (greedy)
https://leetcode.com/problems/minimum-number-of-refueling-stops/description/
youtube.com/watch?v=tAdMNnd3CII
881. Boats to Save People (greedy)
https://leetcode.com/problems/boats-to-save-people/description/
String LCS problems
1312. Minimum Insertion Steps to Make a String Palindrome
https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/description/
1143. Longest Common Subsequence
https://leetcode.com/problems/longest-common-subsequence/
516. Longest Palindromic Subsequence
https://leetcode.com/problems/longest-palindromic-subsequence/description/
Minimum number of deletions to make a string palindrome
https://www.geeksforgeeks.org/minimum-number-deletions-make-string-palindrome/
Heap
2336. Smallest Number in Infinite Set
https://leetcode.com/problems/smallest-number-in-infinite-set/description/
MATRIX
59. Spiral Matrix II
https://leetcode.com/problems/spiral-matrix-ii/description/
Same as house robber
2140. Solving Questions With Brainpower
https://leetcode.com/problems/solving-questions-with-brainpower/description/
mod
2466. Count Ways To Build Good Strings
https://leetcode.com/problems/count-ways-to-build-good-strings/description/
1721. Swapping Nodes in a Linked List
https://leetcode.com/problems/swapping-nodes-in-a-linked-list/description/
Yet Another Problem on Tree
https://www.hackerrank.com/contests/weekly-coding-contest-binary-tree-1664603827/challenges/yet-another-tree-problem-1-1
check chatgpt
894. All Possible Full Binary Trees
https://leetcode.com/problems/all-possible-full-binary-trees/description/?envType=list&envId=54cnzbmv
recursion,return value from recursion
Maximize MEX by adding or subtracting K from Array elements
Atlassian interview
https://www.geeksforgeeks.org/maximize-mex-by-adding-or-subtracting-k-from-array-elements/
https://codeforces.com/contest/1294
———————————————————————GRAPH—————————————————————————
1. Depth First Search (DFS)
2. Breadth First Search (BFS)
3. Topological Sort
4. Union Find
5. Cycle Detection
6. Connected Components
7. Bipartite Graphs
8. Flood Fill
9. Minimum Spanning Tree
10. Shortest Path
GRAPHS
Catalan numbers
96. Unique Binary Search Trees
https://leetcode.com/problems/unique-binary-search-trees/description/
920. Number of Music Playlists
https://leetcode.com/problems/number-of-music-playlists/description/
(very difficult, see image drawn in copy)
2616. Minimize the Maximum Difference of Pairs
https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/description/
https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/solutions/3406380/i-kotlin-recursion-dp-explained-non-binary-search-approach/
again very difficult
see recursion tree in copy
2369. Check if There is a Valid Partition For The Array
https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array/description/
86. Partition List
Linkedlist
https://leetcode.com/problems/partition-list/
542. 01 Matrix
https://leetcode.com/problems/01-matrix/description/
bfs matrix
1615. Maximal Network Rank
https://leetcode.com/problems/maximal-network-rank/description/
https://www.youtube.com/watch?v=lXiv1sw58d0
1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
https://www.youtube.com/watch?v=zl-rLRPpl_s
https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/
Kruskals, DSUF, union find, graph, disjoint set
1584. Min Cost to Connect All Points
prims, graph mst
https://www.geeksforgeeks.org/problems/minimum-spanning-tree/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=minimum-spanning-tree
Krushkals implemented, DSU, disjoint set, Minimum spanning tree MST
Number of Provinces
https://www.geeksforgeeks.org/problems/number-of-provinces/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=number-of-provinces
547. Number of Provinces
DSU
1319. Number of Operations to Make Network Connected
DSU
721. Accounts Merge
DSU
305. Number of Islands II
https://takeuforward.org/graph/number-of-islands-ii-online-queries-dsu-g-51/
DSU
827. Making A Large Island
similar concept as above
DSU
https://takeuforward.org/graph/number-of-islands-ii-online-queries-dsu-g-51/
1101. The Earliest Moment When Everyone Become Friends
google interview
1202. Smallest String With Swaps
DSU, google
947. Most Stones Removed with Same Row or Column
https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/description/
Kosaraju s algorithm, strongly connected components
https://www.geeksforgeeks.org/problems/strongly-connected-components-kosarajus-algo/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=strongly-connected-components-kosarajus-algo
646. Maximum Length of Pair Chain
https://leetcode.com/problems/maximum-length-of-pair-chain/description/
https://leetcode.com/problems/non-overlapping-intervals/description/
LIS
Similar- 435. Non-overlapping Intervals
403. Frog Jump
https://leetcode.com/problems/frog-jump/description/
same as jump game recursion
2483. Minimum Penalty for a Shop
https://leetcode.com/problems/minimum-penalty-for-a-shop/description/
prefix postfix
https://www.youtube.com/watch?v=0d7ShRoOFVE
2707. Extra Characters in a String
https://leetcode.com/problems/extra-characters-in-a-string/description/?envType=daily-question&envId=2023-09-02
Same as Word Break leetcode
725. Split Linked List in Parts
https://leetcode.com/problems/split-linked-list-in-parts/
linkedlist
118. Pascal's Triangle
https://leetcode.com/problems/pascals-triangle/description/?envType=daily-question&envId=2023-09-08
https://www.youtube.com/watch?v=nPVEaB3AjUM
377. Combination Sum IV
https://leetcode.com/problems/combination-sum-iv/description/
1359. Count All Valid Pickup and Delivery Options
https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/description/?envType=daily-question&envId=2023-09-10
maths permutations and combinations
1282. Group the People Given the Group Size They Belong To
https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/description/?envType=daily-question&envId=2023-09-11
1647. Minimum Deletions to Make Character Frequencies Unique
https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique/description/
332. Reconstruct Itinerary
https://leetcode.com/problems/reconstruct-itinerary/description/
Binary search, dfs— can be solved using dijkstra try it later
1631. Path With Minimum Effort
https://leetcode.com/problems/path-with-minimum-effort/description/?envType=daily-question&envId=2023-09-1
778. Swim in Rising Water
https://leetcode.com/problems/swim-in-rising-water/description/
847. Shortest Path Visiting All Nodes
graph, bfs, shortest path, revisting a node, bitmask
1658. Minimum Operations to Reduce X to Zero
Longest subarray sum k
1048. Longest String Chain
https://leetcode.com/problems/longest-string-chain/description/?envType=daily-question&envId=2023-09-23
LIS, dp, recursion, longest increasing subsequence, 01 knapsack
799. Champagne Tower
https://leetcode.com/problems/champagne-tower/description/?envType=daily-question&envId=2023-09-24
Simulation, weird problem
436. Find Right Interval
https://leetcode.com/problems/find-right-interval/description/?envType=study-plan-v2&envId=binary-search
binary search lower bound, find first occurance
https://www.techiedelight.com/find-first-or-last-occurrence-of-a-given-number-sorted-array/
389. Find the Difference
https://leetcode.com/problems/find-the-difference/description/?envType=daily-question&envId=2023-09-25
bitwise
316. Remove Duplicate Letters
https://leetcode.com/problems/remove-duplicate-letters/?envType=daily-question&envId=2023-09-26
String, stack, monotonic increasing stack
880. Decoded String at Index
https://leetcode.com/problems/decoded-string-at-index/description/
456. 132 Pattern
https://leetcode.com/problems/132-pattern/?envType=daily-question&envId=2023-09-30
Monotonic decreasing stack
Longest Distinct characters in string
https://practice.geeksforgeeks.org/problems/longest-distinct-characters-in-string5848/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
https://github.com/arpan-banerjee7/DS_ALGO/blob/master/SlidingWindow/src/slidingwindow/variable/LongestSubstringWithoutRepeatingChars.java
same as longest string with k uniqu
e chars
sliding widow, string, intuit
2038. Remove Colored Pieces if Both Neighbors are the Same Color
https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/description/
simple for loop check, game theory
48. Rotate Image
transpose and reverse each row, for transpose, i=0 to n, j=i t0 n, only upper side of diagonal is needed, or else in place transpose wll not be possible
https://leetcode.com/problems/rotate-image/description/
matrix rotate 90
Binary tree path sum from leaf to leaf- gfg hard
https://practice.geeksforgeeks.org/problems/maximum-path-sum/1
max diameter of binary tree, binary tree maximum path sum
343. Integer Break
https://leetcode.com/problems/integer-break/description/?envType=daily-question&envId=2023-10-06
recursion, dp
1458. Max Dot Product of Two Subsequences
https://leetcode.com/problems/max-dot-product-of-two-subsequences/?envType=daily-question&envId=2023-10-08
todo
2009. Minimum Number of Operations to Make Array Continuous
https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/description/?envType=daily-question&envId=2023-10-10
todo
2125. Number of Laser Beams in a Bank
simple maths, array
2870. Minimum Number of Operations to Make Array Empty
Simple, remainder,0-9 unique reminders, maths, array,hashmap
———————————————————————————————————————————————————————————————————————————
https://www.geeksforgeeks.org/problems/add-1-to-a-number-represented-as-linked-list/1
Add one number to a linked list
Recursion
160. Intersection of Two Linked Lists
https://leetcode.com/problems/intersection-of-two-linked-lists/description/
Linked list striver
Delete all occurrences of a given key in a doubly linked list
https://www.geeksforgeeks.org/problems/delete-all-occurrences-of-a-given-key-in-a-doubly-linked-list/1
No need to delete previous links of deleted nodes, it will be garbage collected
82. Remove Duplicates from Sorted List II
https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/
Linked list striver next.next concept, difficult
Remove duplicates from a sorted doubly linked list