The step 2 is a bruteforce stupid solution. Had to wait for around ~5–7 minutes to have the answer. Launched it on:
openjdk version "21" 2023-09-19 LTS
OpenJDK Runtime Environment Temurin-21+35 (build 21+35-LTS)
OpenJDK 64-Bit Server VM Temurin-21+35 (build 21+35-LTS, mixed mode, sharing)
OS: EndeavourOS Linux x86_64
Host: 20UES00H00 ThinkPad T14 Gen 1
Kernel: 6.6.7-arch1-1
DE: GNOME 45.2
CPU: AMD Ryzen 5 PRO 4650U with Radeon Graphics (12) @ 2.100GHz
GPU: AMD ATI Radeon RX Vega 6
Memory: 11889MiB / 31316MiB
Used this approach from Reddit. The code implementation is mine, but the idea has been taken from that thread on Reddit.
The following comments from Reddit were helpful for me:
The general idea is not mine. However, implementation is mine.