#include <cmath>#include<stack>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain() {intn; cin >>n; vector<int>in(n);for(inti =0; i < n; i ++) cin>>in[i];intret =0; {in.push_back(0); stack<int>stk;for(inti =0; i <in.size(...
Tony's Log HackerRank "AND xor OR" Actually I think problem statement is somewhat misleading. No need to mention range [L, R] at all. The intention is a variation to "Largest Rectangle" which is a classic stack problem on LeetCode. But you need to run Largest Rectangle twice: increased...
Really interesting problem! My 1st solution was DP based, like bottom-up pattern, but it got TLE since it is O(n^2). Then I thought there must be a O(n) solution. And yes there is :) It is an art of counting - what you learnt in your Combinatorics class :) #include <cmath>...
Code will be put in the main category folder (i.e. the first one). Some category may be the Related Topic tags marked by LeetCode. (Add Pattern 0~4 in brackets) TODO: Most of the categories need to be updated. (The date before 2018/9/22) TODO: Mark "Good for Beginner" or "Go...
Once you add all the files in your branch, it time to push your code for generating a pull request. git status This checks whether you are on your created branch or the master branch. If it shows master, type: git checkout <Your Branch Name> Now its time for the Git operations...
(or SJF) CPU Scheduling Python Program Zig-Zag Traversal of Binary Tree in Python Count occurrences of items in Python List Largest Rectangle Hackerrank Solution in Python Unemployment Data Analysis using Python Binary Search Tree in Python Classes and Objects in Python Jump Statement in Python-...
Update: I write stuffHerein Bengali. I probably have one or two basic DP tutorials too. If you understand Bengali, it may help. Note: If you have some other tutorial links and nice problems, mention them. I'll add them here. It'll help me too. ...
959 xor 64 is 1023 → Reply » » Mucosolvan 8 years ago, # ^ | 0 How does this solution look like? → Reply » » » vsp4 8 years ago, # ^ | +3 Use counting sort kindof. So you now how much elements you need to xor and how much will remain the same....
(or SJF) CPU Scheduling Python Program Zig-Zag Traversal of Binary Tree in Python Count occurrences of items in Python List Largest Rectangle Hackerrank Solution in Python Unemployment Data Analysis using Python Binary Search Tree in Python Classes and Objects in Python Jump Statement in Python-...
HackerRank "Xor and Sum" Actually I think it should belong to category of 'Bits Manipulation'.. but still, a really good one. My first reaction was, how to derive from a ^ (b << i) from a ^ (b << (i - 1)), but after some thoughts, I figured out that that should not be...