I saw that some people use trie structure using linked list by pointer while other people built that linked list using array. My question is which approach is more efficient.
I saw that some people use trie structure using linked list by pointer while other people built that linked list using array. My question is which approach is more efficient.
You are given an array of n integers. Using segment tree how can you find for each number how many numbers are smaller than this are exist before that number. For example:
input: (first number is the value of n) 5 1 4 2 5 3
output: 0 1 1 3 2
After trying a problem if I can't find any idea in decent time, I see the editorial or someone else's solution, get the idea and immediately code it and get accepted. Is it okay? Or should I try to solve/code that problem after some days of seeing editorial or someone else's solution? Which is the best strategy to practice programming?