Skip to main content

Posts

Showing posts with the label Search Algorithms

Discover what life after college is really like in India, from work and money to friendships, freedom, responsibility, and adjusting to your first job.

Life After College: What Actually Changes? Graduation can feel surprisingly strange. After years of classes, assignments, exams, college events, attendance, friends sitting nearby, and a routine you mostly understand, one day you simply stop being a student. And then comes the question nobody really answers: what happens after college? You may expect some dramatic transformation. In reality, life after college usually changes in much smaller ways. Your mornings become more structured. Your salary arrives, but so do rent and bills. Your friends become busier. You get more freedom, but you also become responsible for more decisions. Most importantly, graduating does not suddenly make you feel like you have everything figured out. For many Indian students, the transition from college to work life is a mixture of excitement, confusion, independence, pressure, and a little nostalgia. Some changes happen immediately. Others take months or even years to notice. Here is what life ...

33. Search in Rotated Sorted Array

33. Search in Rotated Sorted Array LeetCode 33 – Search in Rotated Sorted Array is a classic binary search problem. The important part is not simply finding the target, but finding it in O(log n) time even though the sorted array has been rotated. The key observation is that, at any point during binary search, at least one half of the current search range will always be sorted . 📄 Problem Statement You are given an integer array nums that was originally sorted in ascending order. All elements are distinct. The array may have been rotated around an unknown pivot. For example: Original: [0,1,2,4,5,6,7] Rotated: [4,5,6,7,0,1,2] You are also given an integer target . Return the index of target if it exists in the array. Otherwise, return -1 . The solution must run in: O(log n) time. 📚 Examples Example 1: Input: nums = [4,5,6,7,0,1,2] target = 0 Output: 4 The target 0 is present at index 4 . Example 2: Input: nums = [4,5,6,7,0,1,2] target = 3 O...