minimum size subarray sum. #+begin_src python res = float('inf') for r in range(len(nums)): total += nums[r] #+end_src git merge-base curr_branch other_branch git diff master... =git log --not master= shows us the commits on =branch=, but not on master #+begin_src python if res == float('inf'): return 0 else: return res #+end_src #+begin_src python while total >= target: res = min(res, r-l+1) total -= nums[l] l+=1 #+end_src =git checkout -- = discards working-tree changes to , replacing it with the version from the index (staging area). if the file is not staged, this effectively means 'restore from head'. Perils: - can permanently lose local edits in your working directory. - does not create commit /safety net safer, modern alternatives include: =git restore = (restore working tree from index) =git restore --source=HEAD = (force restore from last commit. Clique =git diff master...branch= #+begin_src python while r < len(range(nums)): res = min(res, r+l-1) total -= nums[l] l+=1 #+end_src #+begin_src python #+end_src