LeetCode-Solutions
LeetCode-Solutions copied to clipboard
Java script : Find First and Last Position of Element in Sorted Array
Pull Request Template
Description
/**
- 34 Find First and Last Position of Element in Sorted Array
- Medium
- 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].
- Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4]
- Logic : loop through the given array and when target number is found
- set the index as starting position only if the index is first position
- or previous number is not equal to target. For last position keep on
- updating the last position when ever value is equal to target
*/
Put check marks:
Have you made changes in README file ?
- [ ] Added problem & solution under correct topic.
- [ ] Specified Space & Time complexity.
- [ ] Specified difficulty level, tag & Note(if any).
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.
- [ ] Test A
- [ ] Test B
Make sure all below guidelines are followed else PR will get Reject:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code so that it is easy to understand
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published in downstream modules
I can tell this is your first pull request! Thank you I'm so honored. :tada::tada::tada: I'll take a look at it ASAP!