├── Add Digits.java ├── Check Balanced String.java ├── Climbing Stairs.java ├── Find Greatest Common Divisor of Array.cpp ├── Flipping an Image.cpp ├── Matrix Diagonal Sum.cpp ├── Median of Two Sorted Arrays.cpp ├── Merge Sorted Array.cpp ├── Missing Number.java ├── Move Zeroes.java ├── Palindrome Linked List.cpp ├── Power of Three.java ├── README.md ├── Reverse Linked List.cpp ├── Roman to Integer.java ├── Three Divisors.java └── Valid Anagram.cpp /Add Digits.java: -------------------------------------------------------------------------------- 1 | link : https://leetcode.com/problems/add-digits/description/ 2 | 3 | code: 4 | 5 | class Solution { 6 | public int addDigits(int num) { 7 | while(num>=10) 8 | { 9 | int sum=0; 10 | while(num>0) 11 | { 12 | int rem=num%10; 13 | sum=sum + rem; 14 | num=num/10; 15 | } 16 | num=sum; 17 | } 18 | return num; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Check Balanced String.java: -------------------------------------------------------------------------------- 1 | link: https://leetcode.com/problems/check-balanced-string/ 2 | 3 | code: 4 | 5 | class Solution { 6 | public boolean isBalanced(String num) { 7 | int even = 0; 8 | int odd = 0; 9 | for(int i=0;i& nums) { 8 | int min = nums[0]; 9 | int max = nums[0]; 10 | for(int i=0;imax) 13 | { 14 | max = nums[i]; 15 | } 16 | else if(nums[i]> flipAndInvertImage(vector>& image) { 4 | vector a; 5 | for(int i=0;i>& mat) { 4 | int s=0; 5 | for(int i=0;i& nums1, vector& nums2) { 8 | vectora; 9 | double x; 10 | for(int i=0;i& nums1, int m, vector& nums2, int n) { 8 | vectora; 9 | for(int i=0;ia; 9 | vectorb; 10 | while(head!=NULL) 11 | { 12 | a.push_back(head->val); 13 | b.push_back(head->val); 14 | head=head->next; 15 | } 16 | reverse(b.begin(),b.end()); 17 | if(a==b) 18 | { 19 | return true; 20 | } 21 | else 22 | { 23 | return false; 24 | } 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /Power of Three.java: -------------------------------------------------------------------------------- 1 | link : https://leetcode.com/problems/power-of-three/?envType=problem-list-v2&envId=math 2 | 3 | code: 4 | 5 | class Solution { 6 | public: 7 | bool isPowerOfThree(int n) { 8 | if(n <= 0) 9 | { 10 | return false; 11 | } 12 | while(n%3==0) 13 | { 14 | n/=3; 15 | } 16 | return n==1; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ABOVE CODES ARE IN C++ & java 2 | -------------------------------------------------------------------------------- /Reverse Linked List.cpp: -------------------------------------------------------------------------------- 1 | link: https://leetcode.com/problems/reverse-linked-list/description/ 2 | 3 | code: 4 | 5 | class Solution { 6 | public: 7 | ListNode* reverseList(ListNode* head) 8 | { 9 | ListNode*prev=NULL; 10 | ListNode*curr=head; 11 | ListNode*next=NULL; 12 | while(curr!=NULL) 13 | { 14 | next=curr->next; 15 | curr->next=prev; 16 | prev=curr; 17 | curr=next; 18 | } 19 | return prev; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /Roman to Integer.java: -------------------------------------------------------------------------------- 1 | link: https://leetcode.com/problems/roman-to-integer/ 2 | 3 | code: 4 | 5 | class Solution { 6 | public int romanToInt(String s) { 7 | Map roman=new HashMap<>(); 8 | roman.put('I',1); 9 | roman.put('V',5); 10 | roman.put('X',10); 11 | roman.put('L',50); 12 | roman.put('C',100); 13 | roman.put('D',500); 14 | roman.put('M',1000); 15 | int prev=0; 16 | int result=0; 17 | for(int i=s.length()-1;i>=0;i--) 18 | { 19 | int cur=roman.get(s.charAt(i)); 20 | if(cur