Monday, April 28, 2025

My ranking during algorithm contest

My Coding Contests

My TopCoder Contests

Slime harvester

This one have cool GUI, cool multi-agent problem. It creates a distributed environment where the **thread affinity** is a thing. Here is my code in github.

My HackerRank Contests

Contest Solved Rank
Week of Code 37 5/6 181

My LeetCode Contests

2025

Contest Solved Rank
Weekly Contest 432 3/4 413
Biweekly Contest 152 3/4 536

2024

Contest Solved Rank
Weekly Contest 385 3/4 925
Weekly Contest 390 4/4 866
Weekly Contest 402 4/4 753
Biweekly Contest 146 3/4 823
Weekly Contest 429 4/4 567

2023

Contest Solved Rank
Weekly Contest 343 3/4 546
Biweekly Contest 105 4/4 752
Weekly Contest 347 4/4 630
Weekly Contest 368 4/4 316
Weekly Contest 369 3/4 992

2022

Contest Solved Rank
Weekly Contest 296 4/4 826
Biweekly Contest 81 4/4 738
Weekly Contest 322 4/4 287
Weekly Contest 326 4/4 886
Weekly Contest 329 4/4 868
Weekly Contest 333 3/4 583

2021

Contest Solved Rank
Weekly Contest 229 4/4 529
Biweekly Contest 49 3/4 829
Weekly Contest 235 3/4 741
Weekly Contest 237 4/4 902
Biweekly Contest 59 3/4 343
Weekly Contest 255 3/4 434
Weekly Contest 256 3/4 793
Weekly Contest 259 3/4 729
Weekly Contest 267 4/4 556
Weekly Contest 269 4/4 211
Weekly Contest 273 4/4 730
Weekly Contest 283 4/4 1090

2020

Contest Solved Rank
Weekly Contest 221 3/4 900
Weekly Contest 227 3/4 877

Monday, March 10, 2025

Min Treap on top of a Segment tree

As we know treap is the combination of Tree and Heap. It is a tree like structure that has a rigid order when traversed. We can find the lowest value or the lower value than K near a given position.

Treap

Tree Structure
  • As heap it contains the smallest item near the root.
  • As tree, when traversed in-order, it gives the items in sequential order we inserted them. That means that we can insert an item at certain position.
Benefits
We can find the lowest value or the lower value than `K` **near** a given position.
Drawbacks
Treap is not a balanced tree. So the cost of lookup is not always logN.

Treap on top of a Segment Tree

Segment tree structure
  • It has all the values in the leaves.
  • All internal nodes that are not leaves contains the minimum value in the subtree.
Benefits
The query is logN.
Drawbacks
My implementation is fixed size.

My treap

The full implementation is here in this project. You are welcome to try this for example in this problem,