Skip to content

Commit 8679de7

Browse files
committed
Updated the system design directory
1 parent 7fe3057 commit 8679de7

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

Algorithms/design/RangeModuleImpl.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import java.util.ArrayList;
22
import java.util.List;
3+
import java.util.TreeMap;
34

45
/**
56
* Created on: Aug 10, 2021
@@ -23,6 +24,45 @@ public static void main(String[] args) {
2324
System.out.println(obj.queryRange(4, 6));
2425
}
2526

27+
static class RangeModule_2 {
28+
29+
TreeMap<Integer, Integer> map;
30+
31+
public RangeModule_2() {
32+
map = new TreeMap<>();
33+
}
34+
35+
public void addRange(int left, int right) {
36+
Integer start = map.floorKey(left);
37+
Integer end = map.floorKey(right);
38+
if (start != null && map.get(start) >= left) {
39+
left = start;
40+
}
41+
if (end != null && map.get(end) > right) {
42+
right = map.get(end);
43+
}
44+
map.subMap(left, false, right, true).clear();
45+
map.put(left, right);
46+
}
47+
48+
public boolean queryRange(int left, int right) {
49+
Integer start = map.floorKey(left);
50+
return start != null && map.get(start) >= right;
51+
}
52+
53+
public void removeRange(int left, int right) {
54+
Integer start = map.floorKey(left);
55+
Integer end = map.floorKey(right);
56+
if (start != null && map.get(start) > left) {
57+
map.put(start, left);
58+
}
59+
if (end != null && map.get(end) > right) {
60+
map.put(right, map.get(end));
61+
}
62+
map.subMap(left, true, right, false).clear();
63+
}
64+
}
65+
2666
static class RangeModule {
2767
List<Interval> ranges;
2868

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ not related to hard core competitive coding.
6363
6464
## [Contests](https://github.com/neerazz/FAANG/tree/master/Algorithms/Neeraj/contest)
6565

66-
> - [Hackerrank](https://github.com/neerazz/CodingContests/tree/main/hackerrank)
6766
> - [Leetcode](https://github.com/neerazz/CodingContests/tree/main/leetcode)
6867
> - `Includes both Biweekly and Weekly contest.`
68+
> - [Hackerrank](https://github.com/neerazz/CodingContests/tree/main/hackerrank)
6969
> - [Google Kickstart](https://github.com/neerazz/CodingContests/tree/main/goolgeKickstart)
7070
> - [2020](https://github.com/neerazz/CodingContests/tree/main/goolgeKickstart/y2020)
7171
> - [2021](https://github.com/neerazz/CodingContests/tree/main/goolgeKickstart/y2021)
@@ -76,8 +76,8 @@ not related to hard core competitive coding.
7676
> [Tips for System Design](https://github.com/neerazz/faang-system-design/blob/master/Tips_for_system_design.md)
7777
7878
> #### General Design Questions:
79-
> - [Tiny URL](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/systemsdesign/tiny-url)
80-
> - [Cab Booking Service](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/systemsdesign/cab-booking-system)
79+
> - [Tiny URL](https://github.com/neerazz/faang-system-design/tree/master/systemsdesign/tiny-url)
80+
> - [Cab Booking Service](https://github.com/neerazz/faang-system-design/tree/master/systemsdesign/cab-booking-system)
8181
> - [Amazon](https://github.com/neerazz/faang-system-design/blob/master/Resources/architecture-diagrams/Amazon%20System%20Design.png)
8282
> - [Zoom](https://github.com/neerazz/faang-system-design/blob/master/Resources/architecture-diagrams/Zoom%20System%20Design.png)
8383
> - [Google Map](https://github.com/neerazz/faang-system-design/blob/master/Resources/architecture-diagrams/Google%20Maps%20Design.png)
@@ -90,14 +90,14 @@ not related to hard core competitive coding.
9090
9191
## OOPS Design:
9292

93-
> - [Design Library Management System](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/oops/designs/libraryManagment)
94-
> - [Design Parking Lot](https://github.com/neerazz/faang-system-design/blob/master/Neeraj/oops/designs/parkinglot)
95-
> - [Design Call Center](https://github.com/neerazz/faang-system-design/blob/master/Neeraj/oops/designs/callCenter/CallCenter.java)
96-
> - [Design Hit Counter](https://github.com/neerazz/faang-system-design/blob/master/Neeraj/oops/designs/DesignHitCounter.java)
97-
> - [Design Linux Find Command](https://github.com/neerazz/faang-system-design/blob/master/Neeraj/oops/designs/LinuxFindFilter.java)
98-
> - [Design ATM](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/oops/designs/atm)
99-
> - [Design Movie Ticket System](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/oops/designs/movieTicketSystem)
100-
> - [Design Pharmacy Shop](https://github.com/neerazz/faang-system-design/tree/master/Neeraj/oops/designs/pharmacyshop)
93+
> - [Design Library Management System](https://github.com/neerazz/faang-system-design/tree/master/oops/designs/libraryManagment)
94+
> - [Design Parking Lot](https://github.com/neerazz/faang-system-design/blob/master/oops/designs/parkinglot)
95+
> - [Design Call Center](https://github.com/neerazz/faang-system-design/blob/master/oops/designs/callCenter/CallCenter.java)
96+
> - [Design Hit Counter](https://github.com/neerazz/faang-system-design/blob/master/oops/designs/DesignHitCounter.java)
97+
> - [Design Linux Find Command](https://github.com/neerazz/faang-system-design/blob/master/oops/designs/LinuxFindFilter.java)
98+
> - [Design ATM](https://github.com/neerazz/faang-system-design/tree/master/oops/designs/atm)
99+
> - [Design Movie Ticket System](https://github.com/neerazz/faang-system-design/tree/master/oops/designs/movieTicketSystem)
100+
> - [Design Pharmacy Shop](https://github.com/neerazz/faang-system-design/tree/master/oops/designs/pharmacyshop)
101101
>
102102
>> TODO
103103
>> - [Design Vending Machine](https://leetcode.com/discuss/interview-question/982302/FANNG-question-OOP-please-post-your-solutions-to-this)

0 commit comments

Comments
 (0)