Skip to main content

Posts

Showing posts with the label LeetCode 217

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 ...

217. Contains Duplicate

217. Contains Duplicate Difficulty: Easy Problem Statement Given an integer array nums , return true if any value appears at least twice in the array, and return false if every element is distinct . Example 1: Input: nums = [1, 2, 3, 1] Output: true Explanation: The element 1 appears more than once (at indices 0 and 3). Example 2: Input: nums = [1, 2, 3, 4] Output: false Explanation: All elements are unique. Example 3: Input: nums = [1, 1, 1, 3, 3, 4, 3, 2, 4, 2] Output: true Explanation: Several elements appear multiple times: 1 , 3 , 4 , and 2 . Constraints: 1 <= nums.length <= 10⁵ -10⁹ <= nums[i] <= 10⁹ Solution:   import java.util.Arrays; class Solution {     public boolean containsDuplicate ( int [] nums ) {         Arrays . sort (nums); // Sort the array         for ( int i = 1 ; i < nums . length ; i++) {             if (nums[i]...