Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://leetcode.com/190030111
- https://leetcode.com/SurekkaImmanni
- https://leetcode.com/teja2552
- https://leetcode.com/gullyboy118h
- https://leetcode.com/lokeshchalamalasetti
- https://leetcode.com/190030476Harshitha
- https://leetcode.com/190030695
- https://leetcode.com/190031793_BHAVANA_REDDY
- https://leetcode.com/190031350_PRAVALLIKA
- https://leetcode.com/190030803-Akshaya
- https://leetcode.com/MadhuKalyan_CH
- https://leetcode.com/shirdinadhdhulipalla
- https://leetcode.com/190031491
- https://leetcode.com/shoaib22
- https://leetcode.com/190030586_KLU
- https://leetcode.com/190031094_Naveen
- https://leetcode.com/190031674
- https://leetcode.com/sathwik190031311
- https://leetcode.com/190031442
- https://leetcode.com/190031940_samhithagatte
- https://leetcode.com/190030017_lokeswararao
- https://leetcode.com/RahulLalsingh
- https://leetcode.com/birukyemane
- https://leetcode.com/190031500_neehal
- https://leetcode.com/190031449
- https://leetcode.com/190031371
- https://leetcode.com/190031193
- https://leetcode.com/190039012
- https://leetcode.com/190031984_Sainikesh
- https://leetcode.com/190031317_Nagadeepu
- https://leetcode.com/190030188_vamshi
- https://leetcode.com/saichow
- https://leetcode.com/190031753_VOONNA_CHAITANYA
- https://leetcode.com/190030623_Yasaswini
- https://leetcode.com/190031011
- https://leetcode.com/190030664
- https://leetcode.com/venumaddipati
- https://leetcode.com/190030526_prathyushagonuguntla
- https://leetcode.com/190030194
- https://leetcode.com/190030059
- https://leetcode.com/190030363
- https://leetcode.com/190031484
- https://leetcode.com/190040572_Vishwak
- https://leetcode.com/190031328_KLU
- https://leetcode.com/190030155_tejaswinibetina
- https://leetcode.com/s07_190030644
- https://leetcode.com/190031315Krishnateja
- https://leetcode.com/190031600pravalikaThadakamalla
- https://leetcode.com/veda2001
- https://leetcode.com/190031307_klu
- https://leetcode.com/veda2001
- https://leetcode.com/190030306Pravallika
- https://leetcode.com/BejugamRohan
- https://leetcode.com/190030328_lakshmisarayu
- https://leetcode.com/190031903
- https://leetcode.com/sabbellasatyahemanthkumarreddy
- https://leetcode.com/190031438SAIDEEPAK
- https://leetcode.com/190031928
- https://leetcode.com/190031083_Prasad
- https://leetcode.com/190031672_HemanthKumar
- https://leetcode.com/1900300073
- https://leetcode.com/190030748_Ramya
- https://leetcode.com/khalic_190031494
- https://leetcode.com/190031462_SAISUSHEELGUPTAS
- https://leetcode.com/190031136
- https://leetcode.com/190030842
- https://leetcode.com/shyamchandra
- https://leetcode.com/190031467_Sreevani
- https://leetcode.com/shyamchandra
- https://leetcode.com/JangalaTejaswini
- https://leetcode.com/KAMINI_V_S_R_SESHADRI
- https://leetcode.com/31571_nagaprudhvi
- https://leetcode.com/Revanth_12
- https://leetcode.com/Siddhartha_inturu
- https://leetcode.com/190031078_likendhar
- https://leetcode.com/190031468
- https://leetcode.com/190030310
- https://leetcode.com/Tushar_Paraselli
- https://leetcode.com/190030977
- https://leetcode.com/190031504_KLU
- https://leetcode.com/190030225_jaswanthi
- https://leetcode.com/LayekSanjoy
- https://leetcode.com/Mohan_Srinivas_123
- https://leetcode.com/190031580-Tangaturuchandana
- https://leetcode.com/190030398_dvamsi
- https://leetcode.com/190031997
- https://leetcode.com/saisumanthreddychinthakunta
- https://leetcode.com/yaswanth2705
- https://leetcode.com/hemanthkasinadh
- https://leetcode.com/190031522_AvaneeshSai
- https://leetcode.com/190031532_nithin
- https://leetcode.com/ReddyChandana24
- https://leetcode.com/190030319
- https://leetcode.com/190030830
- https://leetcode.com/190030689
- https://leetcode.com/190030684jeswanthkaja
- https://leetcode.com/190031708
- https://leetcode.com/190030454__anilgadde
- https://leetcode.com/Pranathi_j
- https://leetcode.com/190030461
- https://leetcode.com/190031679_vyshnavi
- Copied Solution -
- class Solution {
- public int nearestValidPoint(int x, int y, int[][] points) {
- int n=points.length;
- long min=99999999,d;
- int ans=-1;
- for(int i=0;i<n;i++)
- {
- if(x==points[i][0] || y==points[i][1])
- {
- d=Math.abs(x-points[i][0])+ Math.abs(y-points[i][1]);
- if(d<min)
- {
- min=d;
- ans=i;
- }
- }
- }
- if(ans==-1)
- return -1;
- return ans;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment