Skip to content

Commit

Permalink
Merge pull request AdarshAddee#29 from khushimarothi/cpp
Browse files Browse the repository at this point in the history
Added code of C++
  • Loading branch information
AdarshAddee committed Oct 1, 2022
2 parents ca086fb + 264b436 commit b66b1b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions C++/Pow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//https://leetcode.com/problems/powx-n/

class Solution {
public:
double myPow(double x, int n) {
double res=1;
if (n == INT_MAX)
return x;
else if (n == INT_MIN)
return (x == 1 || x == -1) ? 1 : 0;
if(n<0) x=1/x, n*=-1;
for(int i=1; i<=n;i++){
res=res*x;
}
return res;
}
};

//by - khushi marothi
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| Adarsh Addee | <a href="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/AdarshAddee">Adarsh Addee</a> | <a href="mailto:[email protected]">E-Mail</a> |
| Sarthak Roy | <a href="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/sarthakroy2002">Sarthak Roy</a> | <a href="mailto:[email protected]">E-Mail</a> |
| Suraj Bhandarkar S | <a href="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/Suraj-Bhandarkar-S">Adarsh Addee</a> | <a href="mailto:[email protected]">E-Mail</a> |
| Khushi Marothi | <a href="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/khushimarothi">Khushi Marothi</a> | <a href="mailto:[email protected]">E-Mail</a> |
| Aditya Giri | <a href="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/aditya-464">Aditya Giri</a> | <a href="mailto:[email protected]">E-Mail</a> |
| KryPtoN | <a href="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/Kry9toN">Kry9toN</a> | <a href="mailto:[email protected]">E-Mail</a> |
| Hardik Pratap Singh | <a href="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/hardik-pratap-singh">Hardik Pratap Singh</a> | <a href="mailto:[email protected]">E-Mail</a> |
Expand All @@ -30,6 +31,7 @@




<br>
<h1>
Happy Hacking ❤💻
Expand Down

0 comments on commit b66b1b0

Please sign in to comment.