In a System Design Interview?

Easily Calculate Memory From Bytes to KB, MB, GB, TB

Here is the list with numbers of bytes for each size. With this, you can quickly identify which size metric to show instead of saying a number of bytes. Very helpful for your next System Design Interview. 1 Byte = 8 bit. For simplicity, I am using 1000 as the base instead of 1024 for KB and further calculations. You can mention this to the interviewer to make them aware. ...

October 17, 2023 路 3 min 路 Imran Shaikh
1-n-list-in-java

How to Generate List from 1 to N in Java

There are multiple ways to generate the list from 1 to N or M to N in Java. We will look at 3 with various versions of Java. Using Simple For Loop Just iterate from 1 to N in for a loop and add it to the list. int n = 10; List<Integer> list = new ArrayList<>(n); // 1 to n (inclusive) for (int i = 1; i <= n; i++) { list.add(i); } Using IntStream - Java 8 Using IntStream鈥檚 range for end exclusive and rangeClosed for end inclusive. Here is how. ...

October 15, 2023 路 1 min 路 Imran Shaikh