🚀 Day 39/150 of hashtag#150DaysOfDSA 📌 Task: Happy Number Write an algorithm to determine if a number n is happy. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Return true if n is a happy number, and false if not. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
Algorithm to Determine Happy Number in 150 Days of DSA
More Relevant Posts
-
🚀 Day 28/150 of hashtag#150DaysOfDSA 📌 Task: Contains Duplicate 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. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 49/150 of hashtag#150DaysOfDSA 📌 Task: Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 35/150 of hashtag#150DaysOfDSA 📌 Task: Linked List Creation (Advanced DSA) Create a singly linked list by inserting multiple nodes at the end and display the complete list. Each node should store an integer value and a pointer to the next node. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 48/150 of hashtag#150DaysOfDSA 📌 Task: Valid Perfect Square Given a positive integer num, return true if num is a perfect square or false otherwise. A perfect square is an integer that is the square of an integer (i.e., the product of an integer with itself). You must not use any built-in library function, such as sqrt. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 46/150 of hashtag#150DaysOfDSA 📌 Task: Set Mismatch You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers got duplicated, resulting in one repeated number and one missing number. You are given an integer array nums representing this incorrect set. Find the number that occurs twice and the number that is missing, and return them in the form of an array. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 33/150 of hashtag#150DaysOfDSA 📌 Task: Sqrt(x) Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 43/150 of hashtag#150DaysOfDSA 📌 Task: Find First and Last Position of Element in Sorted Array Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 32/150 of hashtag#150DaysOfDSA 📌 Task: Plus One You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resulting array of digits. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 34/150 of hashtag#150DaysOfDSA 📌 Task: Search Insert Position Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 52/150 of hashtag#150DaysOfDSA 📌 Task: Find the Added Integer You are given two arrays of equal length, nums1 and nums2. Each element in nums1 has been increased (or decreased, in case of negative) by an integer x. As a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies. Return the integer x. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development