Yes, longest chain is determined by chain with most "chainwork". Chainwork is calculated by dividing max value by the blocks target value. Calculate this for all blocks and add them up, the longest chain will have the biggest aggregate chainwork value: https://learnmeabitcoin.com/technical/longest-chain#:~:text=What%20is%20the%20longest%20chain,a%20new%20block%20requires%20energy.
Discussion
Do Bitcoin wallet function differently from every user?
I mean if wallet A has .05 balance,will it show in B's wallet?
Although wallets can have different utilities, the blockchain is immutable. If you in your public key, wallet address, etc... have associated those .05 BTC, not only wallet B, but anyone who knows your pubk, can know that you have that balance.